File: D:/HostingSpaces/SBogers10/farmfun.komma.pro/app/Komma/Components/ComponentType/Types/Hero.php
<?php
namespace App\Komma\Components\ComponentType\Types;
use App\Komma\Components\Component\ViewComponent;
use App\Komma\Components\ComponentType\ComponentTypes;
use App\Komma\Kms\Core\Attributes\Attribute;
use App\Komma\Kms\Core\Attributes\TextArea;
use App\Komma\Kms\Core\Attributes\TextField;
class Hero extends AbstractComponentType
{
public function __construct()
{
$this->id = ComponentTypes::HERO;
$this->name = 'hero';
parent::__construct();
$this->attributes->push((new TextArea('Titel'))
->mapValueFrom(Attribute::ValueFromComponent, 'title')
);
$this->addButton();
$this->attributes->push((new TextField('Youtube video id'))
->mapValueFrom(Attribute::ValueFromComponent, 'video_id')
);
for ($i = 0; $i < 7; $i++) {
$this->attributes->push((new TextField('Zeven zekerheden ('.($i + 1).')'))
->mapValueFrom(Attribute::ValueFromComponent, 'usp_'.$i)
);
}
}
public function prepare(ViewComponent $viewComponent): ViewComponent
{
$certainties = [];
for ($i = 0; $i < 7; $i++) {
$certainties[] = $viewComponent->{'usp_'.$i};
}
$viewComponent->certainties = $certainties;
return $viewComponent;
}
}