<?php
declare(strict_types=1);
namespace Juki\Bundle\AppBundle\EventListener;
use Hitso\Bundle\CommonBundle\Form\Type\TinyMCEType;
use Hitso\Bundle\FormBundle\Event\FormEvent;
use Hitso\Bundle\FormBundle\Form\Type\ImageType;
use Juki\Bundle\AppBundle\Entity\Dictionary\Shop;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
/**
* Class GroupSubscriber
*
* @package Juki\Bundle\AppBundle\EventListener
*/
final class GroupSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
'group_type.form_init' => 'onFormInit',
];
}
public function onFormInit(FormEvent $event)
{
$builder = $event->getBuilder();
$builder->add('shopType',
ChoiceType::class, [
'label' => 'Rodzaj strony',
'choices' => [
'ISM' => Shop::ISM_SYMBOL,
'HSM' => Shop::HSM_SYMBOL,
],
'empty_data' => Shop::ISM_SYMBOL,
'required' => true,
'position' => ['after' => 'slug'],
]
);
$builder->add(
'landingPage',
CheckboxType::class,
[
'label' => 'Landing page',
'required' => false,
'position' => ['before' => 'published'],
]
);
$builder->add(
'description',
TinyMCEType::class,
[
'label' => 'Opis',
'required' => false,
'empty_data' => '',
'config' => [
'toolbar' => [
'styleselect | bullist numlist | bold italic | link unlink | pastetext removeformat | code',
],
],
'position' => ['after' => 'shopType'],
]
);
$builder->add(
'photo',
ImageType::class,
[
'label' => 'Zdjęcie',
'config_name' => 'product_image',
'required' => false,
'position' => ['after' => 'description'],
]
);
}
}