Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7238 from tuka217/api-product
[API][Product] Crud for product
- Loading branch information
Showing
16 changed files
with
1,500 additions
and
142 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
src/Sylius/Bundle/ApiBundle/Form/Extension/ApiProductTypeExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?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 <anna.walasek@lakion.com> | ||
*/ | ||
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'); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getExtendedType() | ||
{ | ||
return ProductType::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.