HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers95/rentman.io/app/Komma/Dynamic/ComponentType/Types/AwardBadges.php
<?php

namespace App\Komma\Dynamic\ComponentType\Types;

use App\Komma\Dynamic\ComponentType\ComponentTypes;
use App\Komma\Kms\Core\Attributes\Attribute;
use App\Komma\Kms\Core\Attributes\Models\SelectOption;
use App\Komma\Kms\Core\Attributes\OnOff;
use App\Komma\Kms\Core\Attributes\Select;

class AwardBadges extends AbstractComponentType
{
    //Set an id that corresponds to the ComponentTypes enum
    protected $id = ComponentTypes::AWARD_BADGES;

    //Set icon and name
    protected $name = 'award-badges';

    // Badge images in /img/badges
    protected $badges = [
        'badge-category-leaders-2023.png',
        'badge-front-runners-2023.png',
        'badge-shortlist-2023.png',
        'badge-best-value-2021.png',
        'badge-functionality-2021.png',
        'badge-dnv-iso27001-managementsysteem-certificatie.png',
        'DNV_EN_ISO_IEC_27001.png',
        'DNV_ES_ISO_IEC_27001.png',
        'DNV_FR_ISO_IEC_27001.png',
        'DNV_IT_ISO_IEC_27001.png',
        'DNV_NL_ISO_IEC_27001.PNG',
    ];

    public function __construct()
    {
        parent::__construct();

        $this->attributes->push(
            (new OnOff())
                ->setLabelText('Remove top margin')
                ->mapValueFrom(Attribute::ValueFromItself, 'no_margin_top')
        );

        $badgeOptions = [];
        foreach ($this->badges as $badge) {
            $badgeOptions[] = (new SelectOption())->setValue($badge)->setContent($badge)->setHtmlContent($badge);
        }

        $numberOfBadges = 6;

        for ($i = 1; $i <= $numberOfBadges; $i++) {
            $this->attributes->push(
                (new Select())
                    ->setItems($badgeOptions)
                    ->mapValueFrom(Attribute::ValueFromItself, 'badge_' . $i)
                    ->setLabelText('badge ' . $i));
        }
    }
}