-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusProductBundlePlugin\Fixture\Factory; | ||
|
||
use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleInterface; | ||
use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
final class ProductBundleFixtureFactory implements ExampleFactoryInterface | ||
{ | ||
private readonly OptionsResolver $optionsResolver; | ||
|
||
public function __construct( | ||
) { | ||
$this->optionsResolver = new OptionsResolver(); | ||
} | ||
|
||
protected function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver | ||
->setDefault('code', '') | ||
->setAllowedTypes('code', 'string') | ||
->setDefault('name', '') | ||
->setAllowedTypes('name', 'string') | ||
->setDefault('price', 0) | ||
->setAllowedTypes('price', 'integer') | ||
->setDefault('quantity', 0) | ||
->setAllowedTypes('quantity', 'integer') | ||
; | ||
} | ||
|
||
public function create(array $options = []): ProductBundleInterface | ||
{ | ||
$options = $this->optionsResolver->resolve($options); | ||
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.1, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.3, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.1, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.2, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.2, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.3, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.3, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.2, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.2, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.2, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.2, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.3, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.3, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.2, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.1, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.3, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.2, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.1, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.3, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.3, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.1, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.2, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.1, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.1, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.1, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.3, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.3, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.3, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.2, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.3, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.3, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.2, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.3, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.2, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.3, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.2, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.2, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.2, Symfony ^6.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.13, PHP 8.2, Symfony ^5.4
Check failure on line 36 in src/Fixture/Factory/ProductBundleFixtureFactory.php GitHub Actions / Sylius ^1.12, PHP 8.3, Symfony ^6.4
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusProductBundlePlugin\Fixture; | ||
|
||
use Sylius\Bundle\CoreBundle\Fixture\AbstractResourceFixture; | ||
use Sylius\Bundle\FixturesBundle\Fixture\FixtureInterface; | ||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; | ||
|
||
final class ProductBundleFixture extends AbstractResourceFixture implements FixtureInterface | ||
{ | ||
protected function configureResourceNode(ArrayNodeDefinition $resourceNode): void | ||
{ | ||
$resourceNodeChildren = $resourceNode->children(); | ||
$resourceNodeChildren->scalarNode('code')->cannotBeEmpty()->end(); | ||
$resourceNodeChildren->scalarNode('name')->cannotBeEmpty()->end(); | ||
$resourceNodeChildren->integerNode('price')->end(); | ||
$resourceNodeChildren->integerNode('quantity')->end(); | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return 'product_bundle'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<service id="bitbag_sylius_product_bundle.fixture.product_bundle" | ||
class="BitBag\SyliusProductBundlePlugin\Fixture\ProductBundleFixture"> | ||
<argument type="service" id="bitbag_sylius_product_bundle.manager.product_bundle"/> | ||
<argument type="service" id="bitbag_sylius_product_bundle.fixture.factory.product_bundle"/> | ||
<tag name="sylius_fixtures.fixture"/> | ||
</service> | ||
<service id="bitbag_sylius_product_bundle.fixture.factory.product_bundle" | ||
class="BitBag\SyliusProductBundlePlugin\Fixture\Factory\ProductBundleFixtureFactory"> | ||
</service> | ||
</services> | ||
</container> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
imports: | ||
- { resource: "@BitBagSyliusProductBundlePlugin/Resources/config/config.yml" } | ||
- { resource: "@BitBagSyliusProductBundlePlugin/Resources/config/config.yml" } | ||
|
||
sylius_fixtures: | ||
suites: | ||
default: | ||
listeners: | ||
orm_purger: ~ | ||
logger: ~ | ||
fixtures: | ||
product_bundle: | ||
options: | ||
custom: | ||
code: 'bundle' | ||
name: Product Bundle | ||
price: 1000 | ||
quantity: 100 |