File: D:/HostingSpaces/blijegasten/blijegasten.be/app/Komma/Components/ComponentType/Types/Reference.php
<?php
namespace App\Komma\Components\ComponentType\Types;
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\Seperator;
use App\Komma\Kms\Core\Attributes\TextArea;
use App\Komma\Kms\Core\Attributes\TextField;
use App\Komma\Kms\Core\Attributes\Title;
class Reference extends AbstractComponentType
{
public function __construct()
{
//Set an id that corresponds to the ComponentTypes enum
$this->id = ComponentTypes::REFERENCE;
//Set icon and name
$this->name = 'reference';
parent::__construct();
$this->attributes->push(new Title('Tekst'));
$this->attributes->push((new TextArea())
->enableTinymceEditor()
->mapValueFrom(Attribute::ValueFromComponent, 'text')
);
$this->attributes->push(new Seperator());
$this->attributes->push(new Title('Referentie'));
$this->attributes->push((new TextField('Naam'))
->mapValueFrom(Attribute::ValueFromComponent, 'name')
);
$this->attributes->push((new TextField('Ondertitel'))
->mapValueFrom(Attribute::ValueFromComponent, 'label')
);
$this->attributes->push(new Seperator());
$this->attributes->push(new Title('Afbeelding'));
$this->attributes->push((new Documents())
->onlyAllowImages()
->setSubFolder('component_uploads')
->setMaxDocuments(1)
->setImageProperties([
(new ImageProperty())->setName('large')->setCropMethod(ImageProperty::Resize)->setWidth(900),
(new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Resize)->setWidth(740),
(new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Resize)->setWidth(375),
])
->setSmallDragAndDropArea()
->mapValueFrom(Attribute::ValueFromComponent, 'image') //Needed to sustain Attribute integrity.
);
}
}