for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\ApiBundle\Form\Extension;
use Sylius\Bundle\ApiBundle\Form\EventSubscriber\RemoveVariantSelectionFieldFormSubscriber;
use Sylius\Bundle\ProductBundle\Form\Type\ProductType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
/**
* @author Anna Walasek <[email protected]>
final class ApiProductTypeExtension extends AbstractTypeExtension
{
* {@inheritdoc}
public function buildForm(FormBuilderInterface $builder, array $options)
$builder->addEventListener(FormEvents::PRE_SUBMIT , function (FormEvent $event) {
$data = $event->getData();
if (!array_key_exists('variantSelectionMethod', $data)) {
$form = $event->getForm();
$form->remove('variantSelectionMethod');
}
});
public function getExtendedType()
return ProductType::class;