File: D:/HostingSpaces/marisrental/boldt.tech/app/Komma/Components/ComponentType/Types/TextImage.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\TextArea;
class TextImage extends AbstractComponentType
{
public function __construct()
{
//Set an id that corresponds to the ComponentTypes enum
$this->id = ComponentTypes::TEXT_IMAGE;
//Set icon and name
$this->name = 'text-image';
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->attributes->push((new OnOff())
->setLabelText("Met hoeken?")
->mapValueFrom(Attribute::ValueFromComponent, 'corners')
);
$this->attributes->push((new OnOff())
->setLabelText("Met verloop?")
->mapValueFrom(Attribute::ValueFromComponent, 'gradient')
);
$this->addButton();
}
}