File: D:/HostingSpaces/SBogers10/inzigd.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\Documents;
use App\Komma\Kms\Core\Attributes\Models\ImageProperty;
use App\Komma\Kms\Core\Attributes\OnOff;
use App\Komma\Kms\Core\Attributes\TextArea;
class Hero extends AbstractComponentType
{
public function __construct()
{
//Set an id that corresponds to the ComponentTypes enum
$this->id = ComponentTypes::HERO;
//Set icon and name
$this->name = 'hero';
parent::__construct();
$this->attributes->push((new TextArea())
->enableTinymceEditor()
->setLabelText('text')
->setPlaceholderText('Ex. Lorum ipsum')
->mapValueFrom(Attribute::ValueFromComponent, 'text')
);
$this->attributes->push((new Documents())
->setLabelText('image')
->onlyAllowImages()
->setSubFolder('component_uploads')
->setMaxDocuments(5)
->setImageProperties([
(new ImageProperty())->setName('original')->setCropMethod(ImageProperty::Resize)->setWidth(2000),
(new ImageProperty())->setName('large')->setCropMethod(ImageProperty::Resize)->setWidth(900),
(new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Resize)->setWidth(600),
(new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Resize)->setWidth(375),
])
->setSmallDragAndDropArea()
->mapValueFrom(Attribute::ValueFromComponent, 'image') //Needed to sustain Attribute integrity.
);
$this->attributes->push((new OnOff())
->setLabelText("Spiegelen")
->mapValueFrom(Attribute::ValueFromComponent, 'reversed')
);
$this->addButton();
}
public function prepare(ViewComponent $viewComponent)
{
// View is custom, so we change the view location.
$viewComponent->view = 'site.organisms.hero';
}
}