diff --git a/UPGRADE.md b/UPGRADE.md index 7755b1e791..50c1775740 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -64,7 +64,7 @@ UPGRADE ### Variation and VariationBundle -* Removed concept of master variant (removed ``$master`` flag from ``Sylius\Component\Variation\Model\Variant``), all usages of **master** variant has been, for now, replaced with **first** variant; +* Removed concept of master variant (removed ``$master`` flag from ``Sylius\Component\Product\Model\Variant``), all usages of **master** variant has been, for now, replaced with **first** variant; * Renamed `presentation` to `name` (`VariantInterface`, `OptionValueInterface`) ### Payment diff --git a/phpspec.yml.dist b/phpspec.yml.dist index a43f589e65..169e01d837 100644 --- a/phpspec.yml.dist +++ b/phpspec.yml.dist @@ -27,7 +27,6 @@ suites: Taxation: { namespace: Sylius\Component\Taxation, psr4_prefix: Sylius\Component\Taxation, spec_path: src/Sylius/Component/Taxation, src_path: src/Sylius/Component/Taxation } Taxonomy: { namespace: Sylius\Component\Taxonomy, psr4_prefix: Sylius\Component\Taxonomy, spec_path: src/Sylius/Component/Taxonomy, src_path: src/Sylius/Component/Taxonomy } User: { namespace: Sylius\Component\User, psr4_prefix: Sylius\Component\User, spec_path: src/Sylius/Component/User, src_path: src/Sylius/Component/User } - Variation: { namespace: Sylius\Component\Variation, psr4_prefix: Sylius\Component\Variation, spec_path: src/Sylius/Component/Variation, src_path: src/Sylius/Component/Variation } AssociationBundle: { namespace: Sylius\Bundle\AssociationBundle, psr4_prefix: Sylius\Bundle\AssociationBundle, spec_path: src/Sylius/Bundle/AssociationBundle, src_path: src/Sylius/Bundle/AssociationBundle } AddressingBundle: { namespace: Sylius\Bundle\AddressingBundle, psr4_prefix: Sylius\Bundle\AddressingBundle, spec_path: src/Sylius/Bundle/AddressingBundle, src_path: src/Sylius/Bundle/AddressingBundle } diff --git a/src/Sylius/Behat/Context/Domain/ManagingOrdersContext.php b/src/Sylius/Behat/Context/Domain/ManagingOrdersContext.php index c5a69100e7..8550c4e20b 100644 --- a/src/Sylius/Behat/Context/Domain/ManagingOrdersContext.php +++ b/src/Sylius/Behat/Context/Domain/ManagingOrdersContext.php @@ -17,7 +17,7 @@ use Sylius\Component\Core\Model\ProductInterface; use Sylius\Component\Core\Repository\OrderRepositoryInterface; use Sylius\Behat\Service\SharedStorageInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; -use Sylius\Component\Variation\Resolver\VariantResolverInterface; +use Sylius\Component\Product\Resolver\VariantResolverInterface; use Webmozart\Assert\Assert; /** diff --git a/src/Sylius/Behat/Context/Setup/OrderContext.php b/src/Sylius/Behat/Context/Setup/OrderContext.php index f2276f8dee..0129128941 100644 --- a/src/Sylius/Behat/Context/Setup/OrderContext.php +++ b/src/Sylius/Behat/Context/Setup/OrderContext.php @@ -37,7 +37,7 @@ use Sylius\Component\Resource\Repository\RepositoryInterface; use Sylius\Component\Shipping\ShipmentTransitions; use Sylius\Component\Customer\Model\CustomerInterface; use Sylius\Component\User\Model\UserInterface; -use Sylius\Component\Variation\Resolver\VariantResolverInterface; +use Sylius\Component\Product\Resolver\VariantResolverInterface; /** * @author Łukasz Chruściel diff --git a/src/Sylius/Behat/Context/Setup/ProductContext.php b/src/Sylius/Behat/Context/Setup/ProductContext.php index c8013fe213..41e2e40723 100644 --- a/src/Sylius/Behat/Context/Setup/ProductContext.php +++ b/src/Sylius/Behat/Context/Setup/ProductContext.php @@ -28,7 +28,7 @@ use Sylius\Component\Product\Model\OptionInterface; use Sylius\Component\Product\Model\OptionValueInterface; use Sylius\Component\Resource\Factory\FactoryInterface; use Sylius\Component\Taxation\Model\TaxCategoryInterface; -use Sylius\Component\Variation\Resolver\VariantResolverInterface; +use Sylius\Component\Product\Resolver\VariantResolverInterface; /** * @author Arkadiusz Krakowiak diff --git a/src/Sylius/Behat/Context/Setup/ProductOptionContext.php b/src/Sylius/Behat/Context/Setup/ProductOptionContext.php index 020e0e0b7d..3dbcae0fd5 100644 --- a/src/Sylius/Behat/Context/Setup/ProductOptionContext.php +++ b/src/Sylius/Behat/Context/Setup/ProductOptionContext.php @@ -17,7 +17,7 @@ use Sylius\Behat\Service\SharedStorageInterface; use Sylius\Component\Product\Model\OptionInterface; use Sylius\Component\Product\Model\OptionValueInterface; use Sylius\Component\Resource\Factory\FactoryInterface; -use Sylius\Component\Variation\Repository\OptionRepositoryInterface; +use Sylius\Component\Product\Repository\OptionRepositoryInterface; /** * @author Grzegorz Sadowski diff --git a/src/Sylius/Behat/Context/Transform/ProductOptionContext.php b/src/Sylius/Behat/Context/Transform/ProductOptionContext.php index 5c184d954f..8da278a2ab 100644 --- a/src/Sylius/Behat/Context/Transform/ProductOptionContext.php +++ b/src/Sylius/Behat/Context/Transform/ProductOptionContext.php @@ -12,7 +12,7 @@ namespace Sylius\Behat\Context\Transform; use Behat\Behat\Context\Context; -use Sylius\Component\Variation\Repository\OptionRepositoryInterface; +use Sylius\Component\Product\Repository\OptionRepositoryInterface; use Webmozart\Assert\Assert; /** diff --git a/src/Sylius/Bundle/CoreBundle/EventListener/ImageUploadListener.php b/src/Sylius/Bundle/CoreBundle/EventListener/ImageUploadListener.php index a35526a468..6e8b5cc7d2 100644 --- a/src/Sylius/Bundle/CoreBundle/EventListener/ImageUploadListener.php +++ b/src/Sylius/Bundle/CoreBundle/EventListener/ImageUploadListener.php @@ -14,7 +14,7 @@ namespace Sylius\Bundle\CoreBundle\EventListener; use Sylius\Component\Core\Model\ProductInterface; use Sylius\Component\Core\Model\ProductVariantInterface; use Sylius\Component\Core\Uploader\ImageUploaderInterface; -use Sylius\Component\Variation\Resolver\VariantResolverInterface; +use Sylius\Component\Product\Resolver\VariantResolverInterface; use Sylius\Component\Core\Model\TaxonInterface; use Symfony\Component\EventDispatcher\GenericEvent; use Webmozart\Assert\Assert; diff --git a/src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductExampleFactory.php b/src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductExampleFactory.php index 807f26d345..a640a9924b 100644 --- a/src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductExampleFactory.php +++ b/src/Sylius/Bundle/CoreBundle/Fixture/Factory/ProductExampleFactory.php @@ -23,7 +23,7 @@ use Sylius\Component\Product\Model\AttributeInterface; use Sylius\Component\Product\Model\AttributeValueInterface; use Sylius\Component\Resource\Factory\FactoryInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; -use Sylius\Component\Variation\Generator\VariantGeneratorInterface; +use Sylius\Component\Product\Generator\VariantGeneratorInterface; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; diff --git a/src/Sylius/Bundle/CoreBundle/spec/EventListener/ImageUploadListenerSpec.php b/src/Sylius/Bundle/CoreBundle/spec/EventListener/ImageUploadListenerSpec.php index 305cbd861e..55175d1e0c 100644 --- a/src/Sylius/Bundle/CoreBundle/spec/EventListener/ImageUploadListenerSpec.php +++ b/src/Sylius/Bundle/CoreBundle/spec/EventListener/ImageUploadListenerSpec.php @@ -20,7 +20,7 @@ use Sylius\Component\Core\Model\ProductVariantInterface; use Sylius\Component\Core\Model\Taxon; use Sylius\Component\Core\Model\TaxonInterface; use Sylius\Component\Core\Uploader\ImageUploaderInterface; -use Sylius\Component\Variation\Resolver\VariantResolverInterface; +use Sylius\Component\Product\Resolver\VariantResolverInterface; use Symfony\Component\EventDispatcher\GenericEvent; /** diff --git a/src/Sylius/Bundle/ProductBundle/Form/EventSubscriber/GenerateProductVariantsSubscriber.php b/src/Sylius/Bundle/ProductBundle/Form/EventSubscriber/GenerateProductVariantsSubscriber.php index 64a9621058..e72f21c399 100644 --- a/src/Sylius/Bundle/ProductBundle/Form/EventSubscriber/GenerateProductVariantsSubscriber.php +++ b/src/Sylius/Bundle/ProductBundle/Form/EventSubscriber/GenerateProductVariantsSubscriber.php @@ -12,7 +12,7 @@ namespace Sylius\Bundle\ProductBundle\Form\EventSubscriber; use Sylius\Component\Product\Model\ProductInterface; -use Sylius\Component\Variation\Generator\VariantGeneratorInterface; +use Sylius\Component\Product\Generator\VariantGeneratorInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; diff --git a/src/Sylius/Bundle/ProductBundle/Form/EventSubscriber/ProductOptionFieldSubscriber.php b/src/Sylius/Bundle/ProductBundle/Form/EventSubscriber/ProductOptionFieldSubscriber.php index d246857e09..c2c750de55 100644 --- a/src/Sylius/Bundle/ProductBundle/Form/EventSubscriber/ProductOptionFieldSubscriber.php +++ b/src/Sylius/Bundle/ProductBundle/Form/EventSubscriber/ProductOptionFieldSubscriber.php @@ -12,7 +12,7 @@ namespace Sylius\Bundle\ProductBundle\Form\EventSubscriber; use Sylius\Component\Product\Model\ProductInterface; -use Sylius\Component\Variation\Resolver\VariantResolverInterface; +use Sylius\Component\Product\Resolver\VariantResolverInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; @@ -62,11 +62,11 @@ class ProductOptionFieldSubscriber implements EventSubscriberInterface $disableOptions = (null !== $this->variantResolver->getVariant($product)) && (false === $product->hasVariants()); $form->add( - 'options', + 'options', 'sylius_product_option_choice', [ - 'required' => false, - 'disabled' => $disableOptions, - 'multiple' => true, + 'required' => false, + 'disabled' => $disableOptions, + 'multiple' => true, 'label' => 'sylius.form.product.options', ] ); diff --git a/src/Sylius/Bundle/ProductBundle/Form/Type/ProductType.php b/src/Sylius/Bundle/ProductBundle/Form/Type/ProductType.php index 817a439212..5bc342857b 100644 --- a/src/Sylius/Bundle/ProductBundle/Form/Type/ProductType.php +++ b/src/Sylius/Bundle/ProductBundle/Form/Type/ProductType.php @@ -15,7 +15,7 @@ use Sylius\Bundle\ProductBundle\Form\EventSubscriber\ProductOptionFieldSubscribe use Sylius\Bundle\ProductBundle\Form\EventSubscriber\SimpleProductSubscriber; use Sylius\Bundle\ResourceBundle\Form\EventSubscriber\AddCodeFormSubscriber; use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType; -use Sylius\Component\Variation\Resolver\VariantResolverInterface; +use Sylius\Component\Product\Resolver\VariantResolverInterface; use Symfony\Component\Form\FormBuilderInterface; /** @@ -40,7 +40,7 @@ class ProductType extends AbstractResourceType $this->variantResolver = $variantResolver; } - + /** * {@inheritdoc} */ diff --git a/src/Sylius/Bundle/ProductBundle/Resources/config/services.xml b/src/Sylius/Bundle/ProductBundle/Resources/config/services.xml index 6699e1b51c..4b02b3a73f 100644 --- a/src/Sylius/Bundle/ProductBundle/Resources/config/services.xml +++ b/src/Sylius/Bundle/ProductBundle/Resources/config/services.xml @@ -17,7 +17,7 @@ http://symfony.com/schema/dic/services/services-1.0.xsd"> - Sylius\Component\Variation\SetBuilder\CartesianSetBuilder + Sylius\Component\Product\SetBuilder\CartesianSetBuilder Sylius\Bundle\ProductBundle\Validator\ProductUniqueValidator diff --git a/src/Sylius/Bundle/VariationBundle/DependencyInjection/Configuration.php b/src/Sylius/Bundle/VariationBundle/DependencyInjection/Configuration.php index 0ae6ea2a76..649d48db03 100644 --- a/src/Sylius/Bundle/VariationBundle/DependencyInjection/Configuration.php +++ b/src/Sylius/Bundle/VariationBundle/DependencyInjection/Configuration.php @@ -24,8 +24,8 @@ use Sylius\Component\Product\Model\OptionValueTranslation; use Sylius\Component\Product\Model\OptionValueTranslationInterface; use Sylius\Component\Resource\Factory\Factory; use Sylius\Component\Resource\Factory\TranslatableFactory; -use Sylius\Component\Variation\Model\OptionTranslation; -use Sylius\Component\Variation\Model\OptionTranslationInterface; +use Sylius\Component\Product\Model\OptionTranslation; +use Sylius\Component\Product\Model\OptionTranslationInterface; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; diff --git a/src/Sylius/Bundle/VariationBundle/Doctrine/ORM/OptionRepository.php b/src/Sylius/Bundle/VariationBundle/Doctrine/ORM/OptionRepository.php index e4b2d7a1a0..3a979f9f23 100644 --- a/src/Sylius/Bundle/VariationBundle/Doctrine/ORM/OptionRepository.php +++ b/src/Sylius/Bundle/VariationBundle/Doctrine/ORM/OptionRepository.php @@ -12,7 +12,7 @@ namespace Sylius\Bundle\VariationBundle\Doctrine\ORM; use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository; -use Sylius\Component\Variation\Repository\OptionRepositoryInterface; +use Sylius\Component\Product\Repository\OptionRepositoryInterface; /** * @author Grzegorz Sadowski diff --git a/src/Sylius/Bundle/VariationBundle/Form/ChoiceList/VariantChoiceList.php b/src/Sylius/Bundle/VariationBundle/Form/ChoiceList/VariantChoiceList.php index 70f30b3f41..8fdadfaab7 100644 --- a/src/Sylius/Bundle/VariationBundle/Form/ChoiceList/VariantChoiceList.php +++ b/src/Sylius/Bundle/VariationBundle/Form/ChoiceList/VariantChoiceList.php @@ -11,7 +11,7 @@ namespace Sylius\Bundle\VariationBundle\Form\ChoiceList; -use Sylius\Component\Variation\Model\VariableInterface; +use Sylius\Component\Product\Model\ProductInterface; use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList; /** @@ -20,9 +20,9 @@ use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList; class VariantChoiceList extends ObjectChoiceList { /** - * @param VariableInterface $variable + * @param ProductInterface $variable */ - public function __construct(VariableInterface $variable) + public function __construct(ProductInterface $variable) { parent::__construct($variable->getVariants(), 'name', [], null, 'id'); } diff --git a/src/Sylius/Bundle/VariationBundle/Form/DataTransformer/VariantToCombinationTransformer.php b/src/Sylius/Bundle/VariationBundle/Form/DataTransformer/VariantToCombinationTransformer.php index 10b038e7b7..f3ca23c5d2 100644 --- a/src/Sylius/Bundle/VariationBundle/Form/DataTransformer/VariantToCombinationTransformer.php +++ b/src/Sylius/Bundle/VariationBundle/Form/DataTransformer/VariantToCombinationTransformer.php @@ -11,9 +11,9 @@ namespace Sylius\Bundle\VariationBundle\Form\DataTransformer; -use Sylius\Component\Variation\Model\OptionValueInterface; -use Sylius\Component\Variation\Model\VariableInterface; -use Sylius\Component\Variation\Model\VariantInterface; +use Sylius\Component\Product\Model\OptionValueInterface; +use Sylius\Component\Product\Model\ProductInterface; +use Sylius\Component\Product\Model\VariantInterface; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\UnexpectedTypeException; @@ -27,14 +27,14 @@ class VariantToCombinationTransformer implements DataTransformerInterface /** * Currently matching variable. * - * @var VariableInterface + * @var ProductInterface */ protected $variable; /** - * @param VariableInterface $variable + * @param ProductInterface $variable */ - public function __construct(VariableInterface $variable) + public function __construct(ProductInterface $variable) { $this->variable = $variable; } diff --git a/src/Sylius/Bundle/VariationBundle/Form/EventListener/BuildVariantFormSubscriber.php b/src/Sylius/Bundle/VariationBundle/Form/EventListener/BuildVariantFormSubscriber.php index 1683daf7f4..7e47ffc952 100644 --- a/src/Sylius/Bundle/VariationBundle/Form/EventListener/BuildVariantFormSubscriber.php +++ b/src/Sylius/Bundle/VariationBundle/Form/EventListener/BuildVariantFormSubscriber.php @@ -66,7 +66,7 @@ class BuildVariantFormSubscriber implements EventSubscriberInterface } // Get related variable object. - $variable = $variant->getObject(); + $variable = $variant->getProduct(); // If the object has options, lets add this configuration field. if ($variable->hasOptions()) { diff --git a/src/Sylius/Bundle/VariationBundle/Form/Type/OptionValueChoiceType.php b/src/Sylius/Bundle/VariationBundle/Form/Type/OptionValueChoiceType.php index 1f95c5e119..62a69d8e4f 100644 --- a/src/Sylius/Bundle/VariationBundle/Form/Type/OptionValueChoiceType.php +++ b/src/Sylius/Bundle/VariationBundle/Form/Type/OptionValueChoiceType.php @@ -11,7 +11,7 @@ namespace Sylius\Bundle\VariationBundle\Form\Type; -use Sylius\Component\Variation\Model\OptionInterface; +use Sylius\Component\Product\Model\OptionInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList; use Symfony\Component\OptionsResolver\Options; diff --git a/src/Sylius/Bundle/VariationBundle/Form/Type/OptionValueCollectionType.php b/src/Sylius/Bundle/VariationBundle/Form/Type/OptionValueCollectionType.php index c6b54c4aae..891d96f984 100644 --- a/src/Sylius/Bundle/VariationBundle/Form/Type/OptionValueCollectionType.php +++ b/src/Sylius/Bundle/VariationBundle/Form/Type/OptionValueCollectionType.php @@ -11,7 +11,7 @@ namespace Sylius\Bundle\VariationBundle\Form\Type; -use Sylius\Component\Variation\Model\OptionInterface; +use Sylius\Component\Product\Model\OptionInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Exception\InvalidConfigurationException; use Symfony\Component\Form\FormBuilderInterface; @@ -50,13 +50,13 @@ class OptionValueCollectionType extends AbstractType !($options['options'] instanceof \Traversable && $options['options'] instanceof \ArrayAccess) ) { throw new InvalidConfigurationException( - 'array or (\Traversable and \ArrayAccess) of "Sylius\Component\Variation\Model\OptionInterface" must be passed to collection' + 'array or (\Traversable and \ArrayAccess) of "Sylius\Component\Product\Model\OptionInterface" must be passed to collection' ); } foreach ($options['options'] as $i => $option) { if (!$option instanceof OptionInterface) { - throw new InvalidConfigurationException('Each object passed as option list must implement "Sylius\Component\Variation\Model\OptionInterface"'); + throw new InvalidConfigurationException('Each object passed as option list must implement "Sylius\Component\Product\Model\OptionInterface"'); } $builder->add((string) $option->getId(), sprintf('sylius_%s_option_value_choice', $this->variableName), [ diff --git a/src/Sylius/Bundle/VariationBundle/Form/Type/VariantChoiceType.php b/src/Sylius/Bundle/VariationBundle/Form/Type/VariantChoiceType.php index 720c621218..0c549971cd 100644 --- a/src/Sylius/Bundle/VariationBundle/Form/Type/VariantChoiceType.php +++ b/src/Sylius/Bundle/VariationBundle/Form/Type/VariantChoiceType.php @@ -12,7 +12,7 @@ namespace Sylius\Bundle\VariationBundle\Form\Type; use Sylius\Bundle\VariationBundle\Form\ChoiceList\VariantChoiceList; -use Sylius\Component\Variation\Model\VariableInterface; +use Sylius\Component\Product\Model\ProductInterface; use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; @@ -66,7 +66,7 @@ class VariantChoiceType extends AbstractType ->setRequired([ 'variable', ]) - ->setAllowedTypes('variable', VariableInterface::class) + ->setAllowedTypes('variable', ProductInterface::class) ; } diff --git a/src/Sylius/Bundle/VariationBundle/Form/Type/VariantMatchType.php b/src/Sylius/Bundle/VariationBundle/Form/Type/VariantMatchType.php index d899e85723..b8f8c2c5a6 100644 --- a/src/Sylius/Bundle/VariationBundle/Form/Type/VariantMatchType.php +++ b/src/Sylius/Bundle/VariationBundle/Form/Type/VariantMatchType.php @@ -13,7 +13,7 @@ namespace Sylius\Bundle\VariationBundle\Form\Type; use Gedmo\Sluggable\Util\Urlizer; use Sylius\Bundle\VariationBundle\Form\DataTransformer\VariantToCombinationTransformer; -use Sylius\Component\Variation\Model\VariableInterface; +use Sylius\Component\Product\Model\ProductInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -61,7 +61,7 @@ class VariantMatchType extends AbstractType ->setRequired([ 'variable', ]) - ->setAllowedTypes('variable', VariableInterface::class) + ->setAllowedTypes('variable', ProductInterface::class) ; } diff --git a/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/Option.orm.xml b/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/Option.orm.xml index 789899b90e..1f0ac9c505 100644 --- a/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/Option.orm.xml +++ b/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/Option.orm.xml @@ -17,7 +17,7 @@ http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd" xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping"> - + diff --git a/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/OptionTranslation.orm.xml b/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/OptionTranslation.orm.xml index b1375f8937..32797e9ee8 100644 --- a/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/OptionTranslation.orm.xml +++ b/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/OptionTranslation.orm.xml @@ -16,7 +16,7 @@ xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - + diff --git a/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/OptionValue.orm.xml b/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/OptionValue.orm.xml index 7df567b57d..4cdcbd82a1 100644 --- a/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/OptionValue.orm.xml +++ b/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/OptionValue.orm.xml @@ -17,7 +17,7 @@ http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd" > - + diff --git a/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/OptionValueTranslation.orm.xml b/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/OptionValueTranslation.orm.xml index f7fd667991..81d3c1ba83 100644 --- a/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/OptionValueTranslation.orm.xml +++ b/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/OptionValueTranslation.orm.xml @@ -12,7 +12,7 @@ xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - diff --git a/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/Variant.orm.xml b/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/Variant.orm.xml index dbc819e61f..18a3587aa9 100644 --- a/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/Variant.orm.xml +++ b/src/Sylius/Bundle/VariationBundle/Resources/config/doctrine/model/Variant.orm.xml @@ -18,7 +18,7 @@ xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping" > - + diff --git a/src/Sylius/Bundle/VariationBundle/Resources/config/serializer/Model.Option.yml b/src/Sylius/Bundle/VariationBundle/Resources/config/serializer/Model.Option.yml index 3bf12d1fd1..317c7c75b0 100644 --- a/src/Sylius/Bundle/VariationBundle/Resources/config/serializer/Model.Option.yml +++ b/src/Sylius/Bundle/VariationBundle/Resources/config/serializer/Model.Option.yml @@ -1,4 +1,4 @@ -Sylius\Component\Variation\Model\Option: +Sylius\Component\Product\Model\Option: exclusion_policy: ALL xml_root_name: option properties: diff --git a/src/Sylius/Bundle/VariationBundle/Resources/config/serializer/Model.OptionValue.yml b/src/Sylius/Bundle/VariationBundle/Resources/config/serializer/Model.OptionValue.yml index 7ac2948853..6d030c4506 100644 --- a/src/Sylius/Bundle/VariationBundle/Resources/config/serializer/Model.OptionValue.yml +++ b/src/Sylius/Bundle/VariationBundle/Resources/config/serializer/Model.OptionValue.yml @@ -1,4 +1,4 @@ -Sylius\Component\Variation\Model\OptionValue: +Sylius\Component\Product\Model\OptionValue: exclusion_policy: ALL xml_root_name: option-value properties: diff --git a/src/Sylius/Bundle/VariationBundle/Resources/config/serializer/Model.Variant.yml b/src/Sylius/Bundle/VariationBundle/Resources/config/serializer/Model.Variant.yml index 79df37a593..22a80c0ac5 100644 --- a/src/Sylius/Bundle/VariationBundle/Resources/config/serializer/Model.Variant.yml +++ b/src/Sylius/Bundle/VariationBundle/Resources/config/serializer/Model.Variant.yml @@ -1,4 +1,4 @@ -Sylius\Component\Variation\Model\Variant: +Sylius\Component\Product\Model\Variant: exclusion_policy: ALL xml_root_name: variant properties: diff --git a/src/Sylius/Bundle/VariationBundle/Resources/config/services.xml b/src/Sylius/Bundle/VariationBundle/Resources/config/services.xml index 1941efe6e4..dedbf3449b 100644 --- a/src/Sylius/Bundle/VariationBundle/Resources/config/services.xml +++ b/src/Sylius/Bundle/VariationBundle/Resources/config/services.xml @@ -22,9 +22,9 @@ Sylius\Bundle\VariationBundle\Validator\VariantUniqueValidator Sylius\Bundle\VariationBundle\Validator\VariantCombinationValidator - Sylius\Component\Variation\Generator\VariantGenerator + Sylius\Component\Product\Generator\VariantGenerator - Sylius\Component\Variation\Resolver\DefaultVariantResolver + Sylius\Component\Product\Resolver\DefaultVariantResolver diff --git a/src/Sylius/Bundle/VariationBundle/Resources/config/validation.xml b/src/Sylius/Bundle/VariationBundle/Resources/config/validation.xml index d682d73b43..3e3c69c6c1 100644 --- a/src/Sylius/Bundle/VariationBundle/Resources/config/validation.xml +++ b/src/Sylius/Bundle/VariationBundle/Resources/config/validation.xml @@ -16,7 +16,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd"> - + @@ -28,7 +28,7 @@ - + @@ -53,7 +53,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -86,7 +86,7 @@ - + diff --git a/src/Sylius/Bundle/VariationBundle/SyliusVariationBundle.php b/src/Sylius/Bundle/VariationBundle/SyliusVariationBundle.php index 0a6c81747f..f3fa370423 100644 --- a/src/Sylius/Bundle/VariationBundle/SyliusVariationBundle.php +++ b/src/Sylius/Bundle/VariationBundle/SyliusVariationBundle.php @@ -37,6 +37,6 @@ class SyliusVariationBundle extends AbstractResourceBundle */ protected function getModelNamespace() { - return 'Sylius\Component\Variation\Model'; + return 'Sylius\Component\Product\Model'; } } diff --git a/src/Sylius/Bundle/VariationBundle/Validator/VariantCombinationValidator.php b/src/Sylius/Bundle/VariationBundle/Validator/VariantCombinationValidator.php index deeb24be6c..9f35180e96 100644 --- a/src/Sylius/Bundle/VariationBundle/Validator/VariantCombinationValidator.php +++ b/src/Sylius/Bundle/VariationBundle/Validator/VariantCombinationValidator.php @@ -11,8 +11,8 @@ namespace Sylius\Bundle\VariationBundle\Validator; -use Sylius\Component\Variation\Model\VariableInterface; -use Sylius\Component\Variation\Model\VariantInterface; +use Sylius\Component\Product\Model\ProductInterface; +use Sylius\Component\Product\Model\VariantInterface; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; @@ -31,7 +31,7 @@ class VariantCombinationValidator extends ConstraintValidator throw new UnexpectedTypeException($value, VariantInterface::class); } - $variable = $value->getObject(); + $variable = $value->getProduct(); if (!$variable->hasVariants() || !$variable->hasOptions()) { return; } @@ -43,11 +43,11 @@ class VariantCombinationValidator extends ConstraintValidator /** * @param VariantInterface $variant - * @param VariableInterface $variable + * @param ProductInterface $variable * * @return bool */ - private function matches(VariantInterface $variant, VariableInterface $variable) + private function matches(VariantInterface $variant, ProductInterface $variable) { foreach ($variable->getVariants() as $existingVariant) { if ($variant === $existingVariant) { diff --git a/src/Sylius/Bundle/VariationBundle/Validator/VariantUniqueValidator.php b/src/Sylius/Bundle/VariationBundle/Validator/VariantUniqueValidator.php index 391db2b8c2..d7c5ea0322 100644 --- a/src/Sylius/Bundle/VariationBundle/Validator/VariantUniqueValidator.php +++ b/src/Sylius/Bundle/VariationBundle/Validator/VariantUniqueValidator.php @@ -12,7 +12,7 @@ namespace Sylius\Bundle\VariationBundle\Validator; use Sylius\Component\Resource\Repository\RepositoryInterface; -use Sylius\Component\Variation\Model\VariantInterface; +use Sylius\Component\Product\Model\VariantInterface; use Symfony\Component\PropertyAccess\PropertyAccess; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; diff --git a/src/Sylius/Bundle/VariationBundle/spec/Form/ChoiceList/VariantChoiceListSpec.php b/src/Sylius/Bundle/VariationBundle/spec/Form/ChoiceList/VariantChoiceListSpec.php index 7150e703fd..a539a9f97f 100644 --- a/src/Sylius/Bundle/VariationBundle/spec/Form/ChoiceList/VariantChoiceListSpec.php +++ b/src/Sylius/Bundle/VariationBundle/spec/Form/ChoiceList/VariantChoiceListSpec.php @@ -12,12 +12,12 @@ namespace spec\Sylius\Bundle\VariationBundle\Form\ChoiceList; use PhpSpec\ObjectBehavior; -use Sylius\Component\Variation\Model\VariableInterface; -use Sylius\Component\Variation\Model\VariantInterface; +use Sylius\Component\Product\Model\ProductInterface; +use Sylius\Component\Product\Model\VariantInterface; final class VariantChoiceListSpec extends ObjectBehavior { - function let(VariableInterface $variable, VariantInterface $variant) + function let(ProductInterface $variable, VariantInterface $variant) { $variable->getVariants()->shouldBeCalled()->willReturn([$variant]); diff --git a/src/Sylius/Bundle/VariationBundle/spec/Form/DataTransformer/VariantToCombinationTransformerSpec.php b/src/Sylius/Bundle/VariationBundle/spec/Form/DataTransformer/VariantToCombinationTransformerSpec.php index da8b1a0edb..b4fbfcaa11 100644 --- a/src/Sylius/Bundle/VariationBundle/spec/Form/DataTransformer/VariantToCombinationTransformerSpec.php +++ b/src/Sylius/Bundle/VariationBundle/spec/Form/DataTransformer/VariantToCombinationTransformerSpec.php @@ -13,15 +13,15 @@ namespace spec\Sylius\Bundle\VariationBundle\Form\DataTransformer; use Doctrine\Common\Collections\Collection; use PhpSpec\ObjectBehavior; -use Sylius\Component\Variation\Model\OptionValueInterface; -use Sylius\Component\Variation\Model\VariableInterface; -use Sylius\Component\Variation\Model\VariantInterface; +use Sylius\Component\Product\Model\OptionValueInterface; +use Sylius\Component\Product\Model\ProductInterface; +use Sylius\Component\Product\Model\VariantInterface; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\UnexpectedTypeException; final class VariantToCombinationTransformerSpec extends ObjectBehavior { - function let(VariableInterface $variable) + function let(ProductInterface $variable) { $this->beConstructedWith($variable); } @@ -71,7 +71,7 @@ final class VariantToCombinationTransformerSpec extends ObjectBehavior } function it_should_reverse_transform_variable_without_variants_into_null( - VariableInterface $variable, + ProductInterface $variable, OptionValueInterface $optionValue ) { $variable->getVariants()->willReturn([]); @@ -80,7 +80,7 @@ final class VariantToCombinationTransformerSpec extends ObjectBehavior } function it_should_reverse_transform_variable_with_variants_if_options_match( - VariableInterface $variable, + ProductInterface $variable, VariantInterface $variant, OptionValueInterface $optionValue ) { @@ -92,7 +92,7 @@ final class VariantToCombinationTransformerSpec extends ObjectBehavior } function it_should_not_reverse_transform_variable_with_variants_if_options_not_match( - VariableInterface $variable, + ProductInterface $variable, VariantInterface $variant, OptionValueInterface $optionValue ) { @@ -104,7 +104,7 @@ final class VariantToCombinationTransformerSpec extends ObjectBehavior } function it_should_not_reverse_transform_variable_with_variants_if_options_are_missing( - VariableInterface $variable, + ProductInterface $variable, VariantInterface $variant ) { $variable->getVariants()->willReturn([$variant]); diff --git a/src/Sylius/Bundle/VariationBundle/spec/Form/EventListener/BuildVariantFormSubscriberSpec.php b/src/Sylius/Bundle/VariationBundle/spec/Form/EventListener/BuildVariantFormSubscriberSpec.php index 3afc25befc..4c22c5693b 100644 --- a/src/Sylius/Bundle/VariationBundle/spec/Form/EventListener/BuildVariantFormSubscriberSpec.php +++ b/src/Sylius/Bundle/VariationBundle/spec/Form/EventListener/BuildVariantFormSubscriberSpec.php @@ -12,10 +12,10 @@ namespace spec\Sylius\Bundle\VariationBundle\Form\EventListener; use PhpSpec\ObjectBehavior; -use Sylius\Component\Variation\Model\OptionInterface; -use Sylius\Component\Variation\Model\OptionValueInterface; -use Sylius\Component\Variation\Model\VariableInterface; -use Sylius\Component\Variation\Model\VariantInterface; +use Sylius\Component\Product\Model\OptionInterface; +use Sylius\Component\Product\Model\OptionValueInterface; +use Sylius\Component\Product\Model\ProductInterface; +use Sylius\Component\Product\Model\VariantInterface; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormFactoryInterface; @@ -45,7 +45,7 @@ final class BuildVariantFormSubscriberSpec extends ObjectBehavior FormEvent $event, FormInterface $form, FormInterface $optionsForm, - VariableInterface $variable, + ProductInterface $variable, VariantInterface $variant, OptionValueInterface $optionValue, OptionInterface $options @@ -53,7 +53,7 @@ final class BuildVariantFormSubscriberSpec extends ObjectBehavior $event->getForm()->shouldBeCalled()->willReturn($form); $event->getData()->shouldBeCalled()->willReturn($variant); - $variant->getObject()->shouldBeCalled()->willReturn($variable); + $variant->getProduct()->shouldBeCalled()->willReturn($variable); $variant->getOptions()->shouldBeCalled()->willReturn([$optionValue]); $variable->getOptions()->shouldBeCalled()->willReturn([$options]); $variable->hasOptions()->shouldBeCalled()->willReturn(true); diff --git a/src/Sylius/Bundle/VariationBundle/spec/Form/Type/OptionValueChoiceTypeSpec.php b/src/Sylius/Bundle/VariationBundle/spec/Form/Type/OptionValueChoiceTypeSpec.php index 99ec0f7292..dc1f0de13a 100644 --- a/src/Sylius/Bundle/VariationBundle/spec/Form/Type/OptionValueChoiceTypeSpec.php +++ b/src/Sylius/Bundle/VariationBundle/spec/Form/Type/OptionValueChoiceTypeSpec.php @@ -13,7 +13,7 @@ namespace spec\Sylius\Bundle\VariationBundle\Form\Type; use PhpSpec\ObjectBehavior; use Prophecy\Argument; -use Sylius\Component\Variation\Model\OptionInterface; +use Sylius\Component\Product\Model\OptionInterface; use Symfony\Component\Form\FormTypeInterface; use Symfony\Component\OptionsResolver\OptionsResolver; diff --git a/src/Sylius/Bundle/VariationBundle/spec/Form/Type/OptionValueCollectionTypeSpec.php b/src/Sylius/Bundle/VariationBundle/spec/Form/Type/OptionValueCollectionTypeSpec.php index 0254f66191..55ab337702 100644 --- a/src/Sylius/Bundle/VariationBundle/spec/Form/Type/OptionValueCollectionTypeSpec.php +++ b/src/Sylius/Bundle/VariationBundle/spec/Form/Type/OptionValueCollectionTypeSpec.php @@ -12,7 +12,7 @@ namespace spec\Sylius\Bundle\VariationBundle\Form\Type; use PhpSpec\ObjectBehavior; -use Sylius\Component\Variation\Model\OptionInterface; +use Sylius\Component\Product\Model\OptionInterface; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormTypeInterface; use Symfony\Component\OptionsResolver\OptionsResolver; diff --git a/src/Sylius/Bundle/VariationBundle/spec/Form/Type/VariantChoiceTypeSpec.php b/src/Sylius/Bundle/VariationBundle/spec/Form/Type/VariantChoiceTypeSpec.php index ebaff9819e..f635aa3434 100644 --- a/src/Sylius/Bundle/VariationBundle/spec/Form/Type/VariantChoiceTypeSpec.php +++ b/src/Sylius/Bundle/VariationBundle/spec/Form/Type/VariantChoiceTypeSpec.php @@ -13,7 +13,7 @@ namespace spec\Sylius\Bundle\VariationBundle\Form\Type; use PhpSpec\ObjectBehavior; use Prophecy\Argument; -use Sylius\Component\Variation\Model\VariableInterface; +use Sylius\Component\Product\Model\ProductInterface; use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormTypeInterface; @@ -55,7 +55,7 @@ final class VariantChoiceTypeSpec extends ObjectBehavior 'variable', ])->shouldBeCalled()->willReturn($resolver); - $resolver->setAllowedTypes('variable', VariableInterface::class)->shouldBeCalled()->willReturn($resolver); + $resolver->setAllowedTypes('variable', ProductInterface::class)->shouldBeCalled()->willReturn($resolver); $this->configureOptions($resolver); } diff --git a/src/Sylius/Bundle/VariationBundle/spec/Form/Type/VariantMatchTypeSpec.php b/src/Sylius/Bundle/VariationBundle/spec/Form/Type/VariantMatchTypeSpec.php index 91801ef927..3fa28298c1 100644 --- a/src/Sylius/Bundle/VariationBundle/spec/Form/Type/VariantMatchTypeSpec.php +++ b/src/Sylius/Bundle/VariationBundle/spec/Form/Type/VariantMatchTypeSpec.php @@ -14,8 +14,8 @@ namespace spec\Sylius\Bundle\VariationBundle\Form\Type; use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Sylius\Bundle\VariationBundle\Form\DataTransformer\VariantToCombinationTransformer; -use Sylius\Component\Variation\Model\OptionInterface; -use Sylius\Component\Variation\Model\VariableInterface; +use Sylius\Component\Product\Model\OptionInterface; +use Sylius\Component\Product\Model\ProductInterface; use Symfony\Component\Form\FormTypeInterface; use Symfony\Component\Form\Test\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -37,7 +37,7 @@ final class VariantMatchTypeSpec extends ObjectBehavior $this->shouldImplement(FormTypeInterface::class); } - function it_builds_a_form(FormBuilderInterface $builder, VariableInterface $variable, OptionInterface $option) + function it_builds_a_form(FormBuilderInterface $builder, ProductInterface $variable, OptionInterface $option) { $variable->getOptions()->shouldBeCalled()->willReturn([$option]); $option->getName()->shouldBeCalled()->willReturn('option_name'); @@ -62,7 +62,7 @@ final class VariantMatchTypeSpec extends ObjectBehavior 'variable', ])->shouldBeCalled()->willReturn($resolver); - $resolver->setAllowedTypes('variable', VariableInterface::class)->shouldBeCalled()->willReturn($resolver); + $resolver->setAllowedTypes('variable', ProductInterface::class)->shouldBeCalled()->willReturn($resolver); $this->configureOptions($resolver); } diff --git a/src/Sylius/Bundle/VariationBundle/spec/Validator/VariantCombinationValidatorSpec.php b/src/Sylius/Bundle/VariationBundle/spec/Validator/VariantCombinationValidatorSpec.php index 475ab4f2be..854f8b1689 100644 --- a/src/Sylius/Bundle/VariationBundle/spec/Validator/VariantCombinationValidatorSpec.php +++ b/src/Sylius/Bundle/VariationBundle/spec/Validator/VariantCombinationValidatorSpec.php @@ -15,9 +15,9 @@ use Doctrine\Common\Collections\ArrayCollection; use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Sylius\Bundle\VariationBundle\Validator\Constraint\VariantCombination; -use Sylius\Component\Variation\Model\OptionValueInterface; -use Sylius\Component\Variation\Model\VariableInterface; -use Sylius\Component\Variation\Model\VariantInterface; +use Sylius\Component\Product\Model\OptionValueInterface; +use Sylius\Component\Product\Model\ProductInterface; +use Sylius\Component\Product\Model\VariantInterface; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Context\ExecutionContextInterface; @@ -40,13 +40,13 @@ final class VariantCombinationValidatorSpec extends ObjectBehavior function it_should_not_add_violation_if_variable_dont_have_options( VariantInterface $variant, - VariableInterface $variable + ProductInterface $variable ) { $constraint = new VariantCombination([ 'message' => 'Variant with given options already exists', ]); - $variant->getObject()->willReturn($variable); + $variant->getProduct()->willReturn($variable); $variable->hasVariants()->willReturn(false); $variable->hasOptions()->willReturn(true); @@ -56,13 +56,13 @@ final class VariantCombinationValidatorSpec extends ObjectBehavior function it_should_not_add_violation_if_variable_dont_have_variants( VariantInterface $variant, - VariableInterface $variable + ProductInterface $variable ) { $constraint = new VariantCombination([ 'message' => 'Variant with given options already exists', ]); - $variant->getObject()->willReturn($variable); + $variant->getProduct()->willReturn($variable); $variable->hasVariants()->willReturn(true); $variable->hasOptions()->willReturn(false); @@ -73,7 +73,7 @@ final class VariantCombinationValidatorSpec extends ObjectBehavior function it_should_add_violation_if_variant_with_given_same_options_already_exists( VariantInterface $variant, VariantInterface $existingVariant, - VariableInterface $variable, + ProductInterface $variable, OptionValueInterface $option, $context ) { @@ -81,7 +81,7 @@ final class VariantCombinationValidatorSpec extends ObjectBehavior 'message' => 'Variant with given options already exists', ]); - $variant->getObject()->willReturn($variable); + $variant->getProduct()->willReturn($variable); $variant->getOptions()->willReturn(new ArrayCollection([$option->getWrappedObject()])); diff --git a/src/Sylius/Bundle/VariationBundle/spec/Validator/VariantUniqueValidatorSpec.php b/src/Sylius/Bundle/VariationBundle/spec/Validator/VariantUniqueValidatorSpec.php index aa0f801483..3910cb2fbf 100644 --- a/src/Sylius/Bundle/VariationBundle/spec/Validator/VariantUniqueValidatorSpec.php +++ b/src/Sylius/Bundle/VariationBundle/spec/Validator/VariantUniqueValidatorSpec.php @@ -15,7 +15,7 @@ use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Sylius\Bundle\VariationBundle\Validator\Constraint\VariantUnique; use Sylius\Component\Resource\Repository\RepositoryInterface; -use Sylius\Component\Variation\Model\VariantInterface; +use Sylius\Component\Product\Model\VariantInterface; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Context\ExecutionContextInterface; diff --git a/src/Sylius/Component/Core/Factory/CartItemFactory.php b/src/Sylius/Component/Core/Factory/CartItemFactory.php index ca449a8637..dd494dc628 100644 --- a/src/Sylius/Component/Core/Factory/CartItemFactory.php +++ b/src/Sylius/Component/Core/Factory/CartItemFactory.php @@ -13,7 +13,7 @@ namespace Sylius\Component\Core\Factory; use Sylius\Component\Core\Model\ProductInterface; use Sylius\Component\Resource\Factory\FactoryInterface; -use Sylius\Component\Variation\Resolver\VariantResolverInterface; +use Sylius\Component\Product\Resolver\VariantResolverInterface; /** * @author Grzegorz Sadowski diff --git a/src/Sylius/Component/Core/spec/Factory/CartItemFactorySpec.php b/src/Sylius/Component/Core/spec/Factory/CartItemFactorySpec.php index 175b9a6288..a9d99c0f78 100644 --- a/src/Sylius/Component/Core/spec/Factory/CartItemFactorySpec.php +++ b/src/Sylius/Component/Core/spec/Factory/CartItemFactorySpec.php @@ -18,7 +18,7 @@ use Sylius\Component\Core\Model\OrderItemInterface; use Sylius\Component\Core\Model\ProductInterface; use Sylius\Component\Core\Model\ProductVariantInterface; use Sylius\Component\Resource\Factory\FactoryInterface; -use Sylius\Component\Variation\Resolver\VariantResolverInterface; +use Sylius\Component\Product\Resolver\VariantResolverInterface; /** * @mixin CartItemFactory diff --git a/src/Sylius/Component/Variation/Generator/VariantGenerator.php b/src/Sylius/Component/Product/Generator/VariantGenerator.php similarity index 84% rename from src/Sylius/Component/Variation/Generator/VariantGenerator.php rename to src/Sylius/Component/Product/Generator/VariantGenerator.php index 1f271a5bd8..27dc606d13 100644 --- a/src/Sylius/Component/Variation/Generator/VariantGenerator.php +++ b/src/Sylius/Component/Product/Generator/VariantGenerator.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Sylius\Component\Variation\Generator; +namespace Sylius\Component\Product\Generator; use Sylius\Component\Resource\Factory\FactoryInterface; -use Sylius\Component\Variation\Model\VariableInterface; -use Sylius\Component\Variation\Model\VariantInterface; -use Sylius\Component\Variation\SetBuilder\SetBuilderInterface; +use Sylius\Component\Product\Model\ProductInterface; +use Sylius\Component\Product\Model\VariantInterface; +use Sylius\Component\Product\SetBuilder\SetBuilderInterface; /** * Variant generator service implementation. @@ -55,7 +55,7 @@ class VariantGenerator implements VariantGeneratorInterface /** * {@inheritdoc} */ - public function generate(VariableInterface $variable) + public function generate(ProductInterface $variable) { if (!$variable->hasOptions()) { throw new \InvalidArgumentException('Cannot generate variants for an object without options.'); @@ -80,16 +80,16 @@ class VariantGenerator implements VariantGeneratorInterface } /** - * @param VariableInterface $variable + * @param ProductInterface $variable * @param array $optionMap * @param mixed $permutation * * @return VariantInterface */ - protected function createVariant(VariableInterface $variable, array $optionMap, $permutation) + protected function createVariant(ProductInterface $variable, array $optionMap, $permutation) { $variant = $this->variantFactory->createNew(); - $variant->setObject($variable); + $variant->setProduct($variable); if (is_array($permutation)) { foreach ($permutation as $id) { diff --git a/src/Sylius/Component/Variation/Generator/VariantGeneratorInterface.php b/src/Sylius/Component/Product/Generator/VariantGeneratorInterface.php similarity index 73% rename from src/Sylius/Component/Variation/Generator/VariantGeneratorInterface.php rename to src/Sylius/Component/Product/Generator/VariantGeneratorInterface.php index e9af0c61ce..741167f38f 100644 --- a/src/Sylius/Component/Variation/Generator/VariantGeneratorInterface.php +++ b/src/Sylius/Component/Product/Generator/VariantGeneratorInterface.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Sylius\Component\Variation\Generator; +namespace Sylius\Component\Product\Generator; -use Sylius\Component\Variation\Model\VariableInterface; +use Sylius\Component\Product\Model\ProductInterface; /** * Interface for variant generating service. @@ -26,7 +26,7 @@ interface VariantGeneratorInterface /** * Generate all possible variants if they don't exist currently. * - * @param VariableInterface $variable + * @param ProductInterface $variable */ - public function generate(VariableInterface $variable); + public function generate(ProductInterface $variable); } diff --git a/src/Sylius/Component/Product/Model/Option.php b/src/Sylius/Component/Product/Model/Option.php index 593e506152..5aa1d14a10 100644 --- a/src/Sylius/Component/Product/Model/Option.php +++ b/src/Sylius/Component/Product/Model/Option.php @@ -11,12 +11,143 @@ namespace Sylius\Component\Product\Model; -use Sylius\Component\Variation\Model\Option as BaseOption; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; +use Sylius\Component\Resource\Model\TimestampableTrait; +use Sylius\Component\Resource\Model\TranslatableTrait; /** * @author Paweł Jędrzejewski * @author Gonzalo Vilaseca */ -class Option extends BaseOption implements OptionInterface +class Option implements OptionInterface { + use TimestampableTrait; + use TranslatableTrait { + __construct as private initializeTranslationsCollection; + } + + /** + * @var mixed + */ + protected $id; + + /** + * @var string + */ + protected $code; + + /** + * Displayed to user. + * + * @var string + */ + protected $name; + + /** + * @var Collection|OptionValueInterface[] + */ + protected $values; + + public function __construct() + { + $this->initializeTranslationsCollection(); + + $this->values = new ArrayCollection(); + $this->createdAt = new \DateTime(); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return $this->getName(); + } + + /** + * {@inheritdoc} + */ + public function getId() + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function getCode() + { + return $this->code; + } + + /** + * {@inheritdoc} + */ + public function setCode($code) + { + $this->code = $code; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->translate()->getName(); + } + + /** + * {@inheritdoc} + */ + public function setName($name) + { + $this->translate()->setName($name); + } + + /** + * {@inheritdoc} + */ + public function getValues() + { + return $this->values; + } + + /** + * {@inheritdoc} + */ + public function setValues(Collection $values) + { + $this->values = $values; + } + + /** + * {@inheritdoc} + */ + public function addValue(OptionValueInterface $value) + { + if (!$this->hasValue($value)) { + $value->setOption($this); + $this->values->add($value); + } + } + + /** + * {@inheritdoc} + */ + public function removeValue(OptionValueInterface $value) + { + if ($this->hasValue($value)) { + $this->values->removeElement($value); + $value->setOption(null); + } + } + + /** + * {@inheritdoc} + */ + public function hasValue(OptionValueInterface $value) + { + return $this->values->contains($value); + } } diff --git a/src/Sylius/Component/Product/Model/OptionInterface.php b/src/Sylius/Component/Product/Model/OptionInterface.php index 72e1fe5e32..21d962f63e 100644 --- a/src/Sylius/Component/Product/Model/OptionInterface.php +++ b/src/Sylius/Component/Product/Model/OptionInterface.php @@ -11,11 +11,57 @@ namespace Sylius\Component\Product\Model; -use Sylius\Component\Variation\Model\OptionInterface as BaseOptionInterface; +use Doctrine\Common\Collections\Collection; +use Sylius\Component\Resource\Model\CodeAwareInterface; +use Sylius\Component\Resource\Model\TimestampableInterface; +use Sylius\Component\Resource\Model\TranslatableInterface; /** + * Model implementing this interface represents the option type, which can be + * attached to an object. + * * @author Paweł Jędrzejewski */ -interface OptionInterface extends BaseOptionInterface +interface OptionInterface extends + CodeAwareInterface, + TimestampableInterface, + OptionTranslationInterface, + TranslatableInterface { + /** + * Returns all option values. + * + * @return Collection|OptionValueInterface[] + */ + public function getValues(); + + /** + * Sets all option values. + * + * @param Collection $optionValues + */ + public function setValues(Collection $optionValues); + + /** + * Adds option value. + * + * @param OptionValueInterface $optionValue + */ + public function addValue(OptionValueInterface $optionValue); + + /** + * Removes option value. + * + * @param OptionValueInterface $optionValue + */ + public function removeValue(OptionValueInterface $optionValue); + + /** + * Checks whether option has given value. + * + * @param OptionValueInterface $optionValue + * + * @return bool + */ + public function hasValue(OptionValueInterface $optionValue); } diff --git a/src/Sylius/Component/Product/Model/OptionTranslation.php b/src/Sylius/Component/Product/Model/OptionTranslation.php index 5f82fe22a3..e397537e84 100644 --- a/src/Sylius/Component/Product/Model/OptionTranslation.php +++ b/src/Sylius/Component/Product/Model/OptionTranslation.php @@ -11,11 +11,44 @@ namespace Sylius\Component\Product\Model; -use Sylius\Component\Variation\Model\OptionTranslation as BaseOptionTranslation; +use Sylius\Component\Resource\Model\AbstractTranslation; /** * @author Gonzalo Vilaseca */ -class OptionTranslation extends BaseOptionTranslation implements OptionTranslationInterface +class OptionTranslation extends AbstractTranslation implements OptionTranslationInterface { + /** + * @var mixed + */ + protected $id; + + /** + * @var string + */ + protected $name; + + /** + * {@inheritdoc} + */ + public function getId() + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + /** + * {@inheritdoc} + */ + public function setName($name) + { + $this->name = $name; + } } diff --git a/src/Sylius/Component/Product/Model/OptionTranslationInterface.php b/src/Sylius/Component/Product/Model/OptionTranslationInterface.php index 7ffa7f4a89..5f4c32aebf 100644 --- a/src/Sylius/Component/Product/Model/OptionTranslationInterface.php +++ b/src/Sylius/Component/Product/Model/OptionTranslationInterface.php @@ -11,11 +11,22 @@ namespace Sylius\Component\Product\Model; -use Sylius\Component\Variation\Model\OptionTranslationInterface as BaseOptionTranslationInterface; +use Sylius\Component\Resource\Model\ResourceInterface; /** * @author Gonzalo Vilaseca */ -interface OptionTranslationInterface extends BaseOptionTranslationInterface +interface OptionTranslationInterface extends ResourceInterface { + /** + * The name displayed to user. + * + * @return string + */ + public function getName(); + + /** + * @param string $name + */ + public function setName($name); } diff --git a/src/Sylius/Component/Product/Model/OptionValue.php b/src/Sylius/Component/Product/Model/OptionValue.php index d739b13b29..2ab333f690 100644 --- a/src/Sylius/Component/Product/Model/OptionValue.php +++ b/src/Sylius/Component/Product/Model/OptionValue.php @@ -11,11 +11,127 @@ namespace Sylius\Component\Product\Model; -use Sylius\Component\Variation\Model\OptionValue as BaseOptionValue; +use Sylius\Component\Resource\Model\TranslatableTrait; /** * @author Paweł Jędrzejewski */ -class OptionValue extends BaseOptionValue implements OptionValueInterface +class OptionValue implements OptionValueInterface { + use TranslatableTrait { + __construct as private initializeTranslationCollection; + } + + /** + * @var mixed + */ + protected $id; + + /** + * @var string + */ + protected $code; + + /** + * @var string + */ + protected $value; + + /** + * @var OptionInterface + */ + protected $option; + + public function __construct() + { + $this->initializeTranslationCollection(); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return $this->getValue(); + } + + /** + * {@inheritdoc} + */ + public function getId() + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function getCode() + { + return $this->code; + } + + /** + * {@inheritdoc} + */ + public function setCode($code) + { + $this->code = $code; + } + + /** + * {@inheritdoc} + */ + public function getOption() + { + return $this->option; + } + + /** + * {@inheritdoc} + */ + public function setOption(OptionInterface $option = null) + { + $this->option = $option; + } + + /** + * {@inheritdoc} + */ + public function getValue() + { + return $this->translate()->getValue(); + } + + /** + * {@inheritdoc} + */ + public function setValue($value) + { + $this->translate()->setValue($value); + } + + /** + * {@inheritdoc} + */ + public function getOptionCode() + { + if (null === $this->option) { + throw new \BadMethodCallException('The option have not been created yet so you cannot access proxy methods.'); + } + + return $this->option->getCode(); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + if (null === $this->option) { + throw new \BadMethodCallException('The option have not been created yet so you cannot access proxy methods.'); + } + + return $this->option->getName(); + } } diff --git a/src/Sylius/Component/Product/Model/OptionValueInterface.php b/src/Sylius/Component/Product/Model/OptionValueInterface.php index 5ff1843a7d..088dc63210 100644 --- a/src/Sylius/Component/Product/Model/OptionValueInterface.php +++ b/src/Sylius/Component/Product/Model/OptionValueInterface.php @@ -11,11 +11,50 @@ namespace Sylius\Component\Product\Model; -use Sylius\Component\Variation\Model\OptionValueInterface as BaseOptionValueInterface; +use Sylius\Component\Resource\Model\CodeAwareInterface; +use Sylius\Component\Resource\Model\ResourceInterface; +use Sylius\Component\Resource\Model\TranslatableInterface; /** * @author Paweł Jędrzejewski */ -interface OptionValueInterface extends BaseOptionValueInterface +interface OptionValueInterface extends ResourceInterface, CodeAwareInterface, TranslatableInterface { + /** + * @return OptionInterface + */ + public function getOption(); + + /** + * @param OptionInterface $option + */ + public function setOption(OptionInterface $option = null); + + /** + * Get internal value. + * + * @return string + */ + public function getValue(); + + /** + * Set internal value. + * + * @param string $value + */ + public function setValue($value); + + /** + * Proxy method to access the presentation of real option object. + * + * @return string The code of object + */ + public function getOptionCode(); + + /** + * Proxy method to access the name of real option object. + * + * @return string The name of object + */ + public function getName(); } diff --git a/src/Sylius/Component/Product/Model/OptionValueTranslation.php b/src/Sylius/Component/Product/Model/OptionValueTranslation.php index 30f4f746e0..44d9915d27 100644 --- a/src/Sylius/Component/Product/Model/OptionValueTranslation.php +++ b/src/Sylius/Component/Product/Model/OptionValueTranslation.php @@ -11,11 +11,44 @@ namespace Sylius\Component\Product\Model; -use Sylius\Component\Variation\Model\OptionValueTranslation as BaseOptionValueTranslation; +use Sylius\Component\Resource\Model\AbstractTranslation; /** * @author Vincenzo Provenza */ -class OptionValueTranslation extends BaseOptionValueTranslation implements OptionValueTranslationInterface +class OptionValueTranslation extends AbstractTranslation implements OptionValueTranslationInterface { + /** + * @var mixed + */ + protected $id; + + /** + * @var string + */ + protected $value; + + /** + * {@inheritdoc} + */ + public function getId() + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function getValue() + { + return $this->value; + } + + /** + * {@inheritdoc} + */ + public function setValue($value) + { + $this->value = $value; + } } diff --git a/src/Sylius/Component/Product/Model/OptionValueTranslationInterface.php b/src/Sylius/Component/Product/Model/OptionValueTranslationInterface.php index a9a7bff806..f03380260a 100644 --- a/src/Sylius/Component/Product/Model/OptionValueTranslationInterface.php +++ b/src/Sylius/Component/Product/Model/OptionValueTranslationInterface.php @@ -11,11 +11,22 @@ namespace Sylius\Component\Product\Model; -use Sylius\Component\Variation\Model\OptionValueTranslationInterface as BaseOptionValueTranslationInterface; +use Sylius\Component\Resource\Model\ResourceInterface; /** * @author Vincenzo Provenza */ -interface OptionValueTranslationInterface extends BaseOptionValueTranslationInterface +interface OptionValueTranslationInterface extends ResourceInterface { + /** + * The name displayed to user. + * + * @return string + */ + public function getValue(); + + /** + * @param string $value + */ + public function setValue($value); } diff --git a/src/Sylius/Component/Product/Model/Product.php b/src/Sylius/Component/Product/Model/Product.php index 7cf74d9a90..7a003f17f7 100644 --- a/src/Sylius/Component/Product/Model/Product.php +++ b/src/Sylius/Component/Product/Model/Product.php @@ -17,8 +17,8 @@ use Sylius\Component\Attribute\Model\AttributeValueInterface as BaseAttributeVal use Sylius\Component\Resource\Model\TimestampableTrait; use Sylius\Component\Resource\Model\ToggleableTrait; use Sylius\Component\Resource\Model\TranslatableTrait; -use Sylius\Component\Variation\Model\OptionInterface as BaseOptionInterface; -use Sylius\Component\Variation\Model\VariantInterface as BaseVariantInterface; +use Sylius\Component\Product\Model\OptionInterface as BaseOptionInterface; +use Sylius\Component\Product\Model\VariantInterface as BaseVariantInterface; /** * @author Paweł Jędrzejewski @@ -472,7 +472,7 @@ class Product implements ProductInterface /** * @return bool */ - public function isSimple() + public function isSimple() { return 1 === $this->variants->count() && !$this->hasOptions(); } diff --git a/src/Sylius/Component/Product/Model/ProductInterface.php b/src/Sylius/Component/Product/Model/ProductInterface.php index 979e1a96c7..d664a54846 100644 --- a/src/Sylius/Component/Product/Model/ProductInterface.php +++ b/src/Sylius/Component/Product/Model/ProductInterface.php @@ -11,6 +11,7 @@ namespace Sylius\Component\Product\Model; +use Doctrine\Common\Collections\Collection; use Sylius\Component\Association\Model\AssociableInterface; use Sylius\Component\Attribute\Model\AttributeSubjectInterface; use Sylius\Component\Resource\Model\CodeAwareInterface; @@ -18,7 +19,6 @@ use Sylius\Component\Resource\Model\SlugAwareInterface; use Sylius\Component\Resource\Model\TimestampableInterface; use Sylius\Component\Resource\Model\ToggleableInterface; use Sylius\Component\Resource\Model\TranslatableInterface; -use Sylius\Component\Variation\Model\VariableInterface; /** * @author Paweł Jędrzejewski @@ -32,9 +32,61 @@ interface ProductInterface extends ProductTranslationInterface, AssociableInterface, CodeAwareInterface, - TranslatableInterface, - VariableInterface + TranslatableInterface { + /** + * @return bool + */ + public function hasVariants(); + /** + * @return Collection|VariantInterface[] + */ + public function getVariants(); + /** + * @param Collection $variants + */ + public function setVariants(Collection $variants); + /** + * @param VariantInterface $variant + */ + public function addVariant(VariantInterface $variant); + /** + * @param VariantInterface $variant + */ + public function removeVariant(VariantInterface $variant); + /** + * @param VariantInterface $variant + * + * @return bool + */ + public function hasVariant(VariantInterface $variant); + /** + * @return bool + */ + public function hasOptions(); + /** + * @return Collection|OptionInterface[] + */ + public function getOptions(); + /** + * @param Collection $options + */ + public function setOptions(Collection $options); + /** + * @param OptionInterface $option + */ + public function addOption(OptionInterface $option); + /** + * @param OptionInterface $option + */ + public function removeOption(OptionInterface $option); + /** + * @param OptionInterface $option + * + * @return bool + */ + public function hasOption(OptionInterface $option); + /** * @return bool */ @@ -74,7 +126,7 @@ interface ProductInterface extends * @param ProductAssociationInterface $association */ public function removeAssociation(ProductAssociationInterface $association); - + /** * @return bool */ diff --git a/src/Sylius/Component/Product/Model/Variant.php b/src/Sylius/Component/Product/Model/Variant.php index ff0a8c1edc..3c431616c2 100644 --- a/src/Sylius/Component/Product/Model/Variant.php +++ b/src/Sylius/Component/Product/Model/Variant.php @@ -11,14 +11,42 @@ namespace Sylius\Component\Product\Model; -use Sylius\Component\Variation\Model\Variant as BaseVariant; -use Sylius\Component\Variation\Model\VariantInterface as BaseVariantInterface; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; +use Sylius\Component\Resource\Model\TimestampableTrait; /** * @author Paweł Jędrzejewski */ -class Variant extends BaseVariant implements VariantInterface +class Variant implements VariantInterface { + use TimestampableTrait; + + /** + * @var mixed + */ + protected $id; + + /** + * @var string + */ + protected $code; + + /** + * @var string + */ + protected $name; + + /** + * @var ProductInterface + */ + protected $product; + + /** + * @var Collection|OptionValueInterface[] + */ + protected $options; + /** * @var \DateTime */ @@ -31,17 +59,102 @@ class Variant extends BaseVariant implements VariantInterface public function __construct() { - parent::__construct(); + $this->options = new ArrayCollection(); + $this->createdAt = new \DateTime(); $this->availableOn = new \DateTime(); } + /** + * {@inheritdoc} + */ + public function getId() + { + return $this->id; + } + + /** + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * @param string $code + */ + public function setCode($code) + { + $this->code = $code; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + /** + * {@inheritdoc} + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * {@inheritdoc} + */ + public function getOptions() + { + return $this->options; + } + + /** + * {@inheritdoc} + */ + public function setOptions(Collection $options) + { + $this->options = $options; + } + + /** + * {@inheritdoc} + */ + public function addOption(OptionValueInterface $option) + { + if (!$this->hasOption($option)) { + $this->options->add($option); + } + } + + /** + * {@inheritdoc} + */ + public function removeOption(OptionValueInterface $option) + { + if ($this->hasOption($option)) { + $this->options->removeElement($option); + } + } + + /** + * {@inheritdoc} + */ + public function hasOption(OptionValueInterface $option) + { + return $this->options->contains($option); + } + /** * {@inheritdoc} */ public function getProduct() { - return parent::getObject(); + return $this->product; } /** @@ -49,7 +162,7 @@ class Variant extends BaseVariant implements VariantInterface */ public function setProduct(ProductInterface $product = null) { - return parent::setObject($product); + $this->product = $product; } /** diff --git a/src/Sylius/Component/Product/Model/VariantInterface.php b/src/Sylius/Component/Product/Model/VariantInterface.php index ce2c3223ff..2ba314ff95 100644 --- a/src/Sylius/Component/Product/Model/VariantInterface.php +++ b/src/Sylius/Component/Product/Model/VariantInterface.php @@ -11,13 +11,56 @@ namespace Sylius\Component\Product\Model; -use Sylius\Component\Variation\Model\VariantInterface as BaseVariantInterface; +use Doctrine\Common\Collections\Collection; +use Sylius\Component\Resource\Model\CodeAwareInterface; +use Sylius\Component\Resource\Model\ResourceInterface; +use Sylius\Component\Resource\Model\TimestampableInterface; /** * @author Paweł Jędrzejewski */ -interface VariantInterface extends BaseVariantInterface +interface VariantInterface extends TimestampableInterface, ResourceInterface, CodeAwareInterface { + /** + * This should be generated from option values + * when no other is set. + * + * @return string + */ + public function getName(); + + /** + * @param string $name + */ + public function setName($name); + + /** + * @return Collection|OptionValueInterface[] + */ + public function getOptions(); + + /** + * @param Collection $options + */ + public function setOptions(Collection $options); + + /** + * @param OptionValueInterface $option + */ + public function addOption(OptionValueInterface $option); + + /** + * @param OptionValueInterface $option + */ + public function removeOption(OptionValueInterface $option); + + /** + * @param OptionValueInterface $option + * + * @return bool + */ + public function hasOption(OptionValueInterface $option); + /** * @return ProductInterface */ diff --git a/src/Sylius/Component/Variation/Repository/OptionRepositoryInterface.php b/src/Sylius/Component/Product/Repository/OptionRepositoryInterface.php similarity index 84% rename from src/Sylius/Component/Variation/Repository/OptionRepositoryInterface.php rename to src/Sylius/Component/Product/Repository/OptionRepositoryInterface.php index d2b6beb714..d79b57384a 100644 --- a/src/Sylius/Component/Variation/Repository/OptionRepositoryInterface.php +++ b/src/Sylius/Component/Product/Repository/OptionRepositoryInterface.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace Sylius\Component\Variation\Repository; +namespace Sylius\Component\Product\Repository; use Sylius\Component\Resource\Repository\RepositoryInterface; -use Sylius\Component\Variation\Model\OptionInterface; +use Sylius\Component\Product\Model\OptionInterface; /** * @author Grzegorz Sadowski diff --git a/src/Sylius/Component/Variation/Resolver/DefaultVariantResolver.php b/src/Sylius/Component/Product/Resolver/DefaultVariantResolver.php similarity index 75% rename from src/Sylius/Component/Variation/Resolver/DefaultVariantResolver.php rename to src/Sylius/Component/Product/Resolver/DefaultVariantResolver.php index ca1f89bd3e..9c8fe1fe89 100644 --- a/src/Sylius/Component/Variation/Resolver/DefaultVariantResolver.php +++ b/src/Sylius/Component/Product/Resolver/DefaultVariantResolver.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Sylius\Component\Variation\Resolver; +namespace Sylius\Component\Product\Resolver; -use Sylius\Component\Variation\Model\VariableInterface; +use Sylius\Component\Product\Model\ProductInterface; /** * @author Anna Walasek @@ -21,12 +21,12 @@ final class DefaultVariantResolver implements VariantResolverInterface /** * {@inheritdoc} */ - public function getVariant(VariableInterface $subject) + public function getVariant(ProductInterface $subject) { if ($subject->getVariants()->isEmpty()) { return null; } - + return $subject->getVariants()->first(); } } diff --git a/src/Sylius/Component/Variation/Resolver/VariantResolverInterface.php b/src/Sylius/Component/Product/Resolver/VariantResolverInterface.php similarity index 59% rename from src/Sylius/Component/Variation/Resolver/VariantResolverInterface.php rename to src/Sylius/Component/Product/Resolver/VariantResolverInterface.php index c13d34601b..26c24b381e 100644 --- a/src/Sylius/Component/Variation/Resolver/VariantResolverInterface.php +++ b/src/Sylius/Component/Product/Resolver/VariantResolverInterface.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace Sylius\Component\Variation\Resolver; +namespace Sylius\Component\Product\Resolver; -use Sylius\Component\Variation\Model\VariableInterface; -use Sylius\Component\Variation\Model\VariantInterface; +use Sylius\Component\Product\Model\ProductInterface; +use Sylius\Component\Product\Model\VariantInterface; /** * @author Anna Walasek @@ -20,9 +20,9 @@ use Sylius\Component\Variation\Model\VariantInterface; interface VariantResolverInterface { /** - * @param VariableInterface $subject + * @param ProductInterface $subject * * @return VariantInterface */ - public function getVariant(VariableInterface $subject); + public function getVariant(ProductInterface $subject); } diff --git a/src/Sylius/Component/Variation/SetBuilder/CartesianSetBuilder.php b/src/Sylius/Component/Product/SetBuilder/CartesianSetBuilder.php similarity index 97% rename from src/Sylius/Component/Variation/SetBuilder/CartesianSetBuilder.php rename to src/Sylius/Component/Product/SetBuilder/CartesianSetBuilder.php index 3a09cf3361..a634de200b 100644 --- a/src/Sylius/Component/Variation/SetBuilder/CartesianSetBuilder.php +++ b/src/Sylius/Component/Product/SetBuilder/CartesianSetBuilder.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sylius\Component\Variation\SetBuilder; +namespace Sylius\Component\Product\SetBuilder; /** * Builds the Cartesian product set from one or more given sets. diff --git a/src/Sylius/Component/Variation/SetBuilder/SetBuilderInterface.php b/src/Sylius/Component/Product/SetBuilder/SetBuilderInterface.php similarity index 92% rename from src/Sylius/Component/Variation/SetBuilder/SetBuilderInterface.php rename to src/Sylius/Component/Product/SetBuilder/SetBuilderInterface.php index 536198d1aa..c4e0cf796c 100644 --- a/src/Sylius/Component/Variation/SetBuilder/SetBuilderInterface.php +++ b/src/Sylius/Component/Product/SetBuilder/SetBuilderInterface.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sylius\Component\Variation\SetBuilder; +namespace Sylius\Component\Product\SetBuilder; /** * Build a product set from one or more given sets. diff --git a/src/Sylius/Component/Product/spec/Factory/ProductFactorySpec.php b/src/Sylius/Component/Product/spec/Factory/ProductFactorySpec.php index 6ed393e0ce..cabffe106d 100644 --- a/src/Sylius/Component/Product/spec/Factory/ProductFactorySpec.php +++ b/src/Sylius/Component/Product/spec/Factory/ProductFactorySpec.php @@ -15,7 +15,7 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Product\Factory\ProductFactoryInterface; use Sylius\Component\Product\Model\ProductInterface; use Sylius\Component\Resource\Factory\FactoryInterface; -use Sylius\Component\Variation\Model\VariantInterface; +use Sylius\Component\Product\Model\VariantInterface; /** * @author Paweł Jędrzejewski diff --git a/src/Sylius/Component/Variation/spec/Generator/VariantGeneratorSpec.php b/src/Sylius/Component/Product/spec/Generator/VariantGeneratorSpec.php similarity index 82% rename from src/Sylius/Component/Variation/spec/Generator/VariantGeneratorSpec.php rename to src/Sylius/Component/Product/spec/Generator/VariantGeneratorSpec.php index e543e6a4be..4f7cc75fb6 100644 --- a/src/Sylius/Component/Variation/spec/Generator/VariantGeneratorSpec.php +++ b/src/Sylius/Component/Product/spec/Generator/VariantGeneratorSpec.php @@ -9,17 +9,17 @@ * file that was distributed with this source code. */ -namespace spec\Sylius\Component\Variation\Generator; +namespace spec\Sylius\Component\Product\Generator; use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Sylius\Component\Resource\Factory\FactoryInterface; -use Sylius\Component\Variation\Generator\VariantGeneratorInterface; -use Sylius\Component\Variation\Model\OptionInterface; -use Sylius\Component\Variation\Model\OptionValue; -use Sylius\Component\Variation\Model\VariableInterface; -use Sylius\Component\Variation\Model\VariantInterface; -use Sylius\Component\Variation\SetBuilder\SetBuilderInterface; +use Sylius\Component\Product\Generator\VariantGeneratorInterface; +use Sylius\Component\Product\Model\OptionInterface; +use Sylius\Component\Product\Model\OptionValue; +use Sylius\Component\Product\Model\ProductInterface; +use Sylius\Component\Product\Model\VariantInterface; +use Sylius\Component\Product\SetBuilder\SetBuilderInterface; /** * @author Adam Elsodaney @@ -33,7 +33,7 @@ final class VariantGeneratorSpec extends ObjectBehavior function it_is_initializable() { - $this->shouldHaveType('Sylius\Component\Variation\Generator\VariantGenerator'); + $this->shouldHaveType('Sylius\Component\Product\Generator\VariantGenerator'); } function it_is_a_Sylius_variant_generator() @@ -41,7 +41,7 @@ final class VariantGeneratorSpec extends ObjectBehavior $this->shouldImplement(VariantGeneratorInterface::class); } - function it_cannot_generate_variants_for_an_object_without_options(VariableInterface $variable) + function it_cannot_generate_variants_for_an_object_without_options(ProductInterface $variable) { $variable->hasOptions()->willReturn(false); @@ -55,7 +55,7 @@ final class VariantGeneratorSpec extends ObjectBehavior OptionValue $redColor, OptionValue $whiteColor, SetBuilderInterface $setBuilder, - VariableInterface $productVariable, + ProductInterface $productVariable, VariantInterface $permutationVariant ) { $productVariable->hasOptions()->willReturn(true); @@ -76,8 +76,8 @@ final class VariantGeneratorSpec extends ObjectBehavior ]); $variantFactory->createNew()->willReturn($permutationVariant); - $permutationVariant->setObject($productVariable)->shouldBeCalled(); - $permutationVariant->addOption(Argument::type('Sylius\Component\Variation\Model\OptionValue'))->shouldBeCalled(); + $permutationVariant->setProduct($productVariable)->shouldBeCalled(); + $permutationVariant->addOption(Argument::type('Sylius\Component\Product\Model\OptionValue'))->shouldBeCalled(); $productVariable->addVariant($permutationVariant)->shouldBeCalled(); $this->generate($productVariable); @@ -94,7 +94,7 @@ final class VariantGeneratorSpec extends ObjectBehavior OptionValue $smallSize, OptionValue $whiteColor, SetBuilderInterface $setBuilder, - VariableInterface $productVariable, + ProductInterface $productVariable, VariantInterface $permutationVariant ) { $productVariable->hasOptions()->willReturn(true); @@ -127,8 +127,8 @@ final class VariantGeneratorSpec extends ObjectBehavior ]); $variantFactory->createNew()->willReturn($permutationVariant); - $permutationVariant->setObject($productVariable)->shouldBeCalled(); - $permutationVariant->addOption(Argument::type('Sylius\Component\Variation\Model\OptionValue'))->shouldBeCalled(); + $permutationVariant->setProduct($productVariable)->shouldBeCalled(); + $permutationVariant->addOption(Argument::type('Sylius\Component\Product\Model\OptionValue'))->shouldBeCalled(); $productVariable->addVariant($permutationVariant)->shouldBeCalled(); $this->generate($productVariable); diff --git a/src/Sylius/Component/Variation/spec/Resolver/DefaultVariantResolverSpec.php b/src/Sylius/Component/Product/spec/Resolver/DefaultVariantResolverSpec.php similarity index 73% rename from src/Sylius/Component/Variation/spec/Resolver/DefaultVariantResolverSpec.php rename to src/Sylius/Component/Product/spec/Resolver/DefaultVariantResolverSpec.php index 8923ce18f3..2b3d7b18e5 100644 --- a/src/Sylius/Component/Variation/spec/Resolver/DefaultVariantResolverSpec.php +++ b/src/Sylius/Component/Product/spec/Resolver/DefaultVariantResolverSpec.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace spec\Sylius\Component\Variation\Resolver; +namespace spec\Sylius\Component\Product\Resolver; use Doctrine\Common\Collections\Collection; -use Sylius\Component\Variation\Model\VariableInterface; -use Sylius\Component\Variation\Resolver\DefaultVariantResolver; +use Sylius\Component\Product\Model\ProductInterface; +use Sylius\Component\Product\Resolver\DefaultVariantResolver; use PhpSpec\ObjectBehavior; use Prophecy\Argument; -use Sylius\Component\Variation\Model\VariantInterface; -use Sylius\Component\Variation\Resolver\VariantResolverInterface; +use Sylius\Component\Product\Model\VariantInterface; +use Sylius\Component\Product\Resolver\VariantResolverInterface; /** * @author Anna Walasek @@ -35,7 +35,7 @@ final class DefaultVariantResolverSpec extends ObjectBehavior } function it_returns_first_variant( - VariableInterface $product, + ProductInterface $product, VariantInterface $variant, Collection $variants ) { @@ -46,7 +46,7 @@ final class DefaultVariantResolverSpec extends ObjectBehavior $this->getVariant($product)->shouldReturn($variant); } - function it_returns_null_if_first_variant_is_not_definied(VariableInterface $product, Collection $variants) + function it_returns_null_if_first_variant_is_not_definied(ProductInterface $product, Collection $variants) { $product->getVariants()->willReturn($variants); $variants->isEmpty()->willReturn(true); diff --git a/src/Sylius/Component/Variation/spec/SetBuilder/CartesianSetBuilderSpec.php b/src/Sylius/Component/Product/spec/SetBuilder/CartesianSetBuilderSpec.php similarity index 95% rename from src/Sylius/Component/Variation/spec/SetBuilder/CartesianSetBuilderSpec.php rename to src/Sylius/Component/Product/spec/SetBuilder/CartesianSetBuilderSpec.php index 7a231436b7..cd8b35d97e 100644 --- a/src/Sylius/Component/Variation/spec/SetBuilder/CartesianSetBuilderSpec.php +++ b/src/Sylius/Component/Product/spec/SetBuilder/CartesianSetBuilderSpec.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace spec\Sylius\Component\Variation\SetBuilder; +namespace spec\Sylius\Component\Product\SetBuilder; use PhpSpec\ObjectBehavior; use Prophecy\Argument; -use Sylius\Component\Variation\SetBuilder\SetBuilderInterface; +use Sylius\Component\Product\SetBuilder\SetBuilderInterface; /** * @author Adam Elsodaney diff --git a/src/Sylius/Component/Variation/.gitignore b/src/Sylius/Component/Variation/.gitignore deleted file mode 100644 index 46aed33710..0000000000 --- a/src/Sylius/Component/Variation/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -vendor/ -bin/ - -composer.phar -composer.lock diff --git a/src/Sylius/Component/Variation/CHANGELOG.md b/src/Sylius/Component/Variation/CHANGELOG.md deleted file mode 100644 index 376608b395..0000000000 --- a/src/Sylius/Component/Variation/CHANGELOG.md +++ /dev/null @@ -1,7 +0,0 @@ -CHANGELOG -========= - -### v0.10.0 - -* Initial dev release. - diff --git a/src/Sylius/Component/Variation/LICENSE b/src/Sylius/Component/Variation/LICENSE deleted file mode 100644 index 592b2c08e2..0000000000 --- a/src/Sylius/Component/Variation/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2011-2016 Paweł Jędrzejewski - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/src/Sylius/Component/Variation/Model/Option.php b/src/Sylius/Component/Variation/Model/Option.php deleted file mode 100644 index bf8053d64d..0000000000 --- a/src/Sylius/Component/Variation/Model/Option.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @author Gonzalo Vilaseca - */ -class Option implements OptionInterface -{ - use TimestampableTrait; - use TranslatableTrait { - __construct as private initializeTranslationsCollection; - } - - /** - * @var mixed - */ - protected $id; - - /** - * @var string - */ - protected $code; - - /** - * Displayed to user. - * - * @var string - */ - protected $name; - - /** - * @var Collection|OptionValueInterface[] - */ - protected $values; - - public function __construct() - { - $this->initializeTranslationsCollection(); - - $this->values = new ArrayCollection(); - $this->createdAt = new \DateTime(); - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - return $this->getName(); - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getCode() - { - return $this->code; - } - - /** - * {@inheritdoc} - */ - public function setCode($code) - { - $this->code = $code; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->translate()->getName(); - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->translate()->setName($name); - } - - /** - * {@inheritdoc} - */ - public function getValues() - { - return $this->values; - } - - /** - * {@inheritdoc} - */ - public function setValues(Collection $values) - { - $this->values = $values; - } - - /** - * {@inheritdoc} - */ - public function addValue(OptionValueInterface $value) - { - if (!$this->hasValue($value)) { - $value->setOption($this); - $this->values->add($value); - } - } - - /** - * {@inheritdoc} - */ - public function removeValue(OptionValueInterface $value) - { - if ($this->hasValue($value)) { - $this->values->removeElement($value); - $value->setOption(null); - } - } - - /** - * {@inheritdoc} - */ - public function hasValue(OptionValueInterface $value) - { - return $this->values->contains($value); - } -} diff --git a/src/Sylius/Component/Variation/Model/OptionInterface.php b/src/Sylius/Component/Variation/Model/OptionInterface.php deleted file mode 100644 index 71cde01415..0000000000 --- a/src/Sylius/Component/Variation/Model/OptionInterface.php +++ /dev/null @@ -1,67 +0,0 @@ - - */ -interface OptionInterface extends - CodeAwareInterface, - TimestampableInterface, - OptionTranslationInterface, - TranslatableInterface -{ - /** - * Returns all option values. - * - * @return Collection|OptionValueInterface[] - */ - public function getValues(); - - /** - * Sets all option values. - * - * @param Collection $optionValues - */ - public function setValues(Collection $optionValues); - - /** - * Adds option value. - * - * @param OptionValueInterface $optionValue - */ - public function addValue(OptionValueInterface $optionValue); - - /** - * Removes option value. - * - * @param OptionValueInterface $optionValue - */ - public function removeValue(OptionValueInterface $optionValue); - - /** - * Checks whether option has given value. - * - * @param OptionValueInterface $optionValue - * - * @return bool - */ - public function hasValue(OptionValueInterface $optionValue); -} diff --git a/src/Sylius/Component/Variation/Model/OptionTranslation.php b/src/Sylius/Component/Variation/Model/OptionTranslation.php deleted file mode 100644 index 43ea9ede74..0000000000 --- a/src/Sylius/Component/Variation/Model/OptionTranslation.php +++ /dev/null @@ -1,54 +0,0 @@ - - */ -class OptionTranslation extends AbstractTranslation implements OptionTranslationInterface -{ - /** - * @var mixed - */ - protected $id; - - /** - * @var string - */ - protected $name; - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->name = $name; - } -} diff --git a/src/Sylius/Component/Variation/Model/OptionTranslationInterface.php b/src/Sylius/Component/Variation/Model/OptionTranslationInterface.php deleted file mode 100644 index 69a677db02..0000000000 --- a/src/Sylius/Component/Variation/Model/OptionTranslationInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - */ -interface OptionTranslationInterface extends ResourceInterface -{ - /** - * The name displayed to user. - * - * @return string - */ - public function getName(); - - /** - * @param string $name - */ - public function setName($name); -} diff --git a/src/Sylius/Component/Variation/Model/OptionValue.php b/src/Sylius/Component/Variation/Model/OptionValue.php deleted file mode 100644 index fa18c0311b..0000000000 --- a/src/Sylius/Component/Variation/Model/OptionValue.php +++ /dev/null @@ -1,137 +0,0 @@ - - */ -class OptionValue implements OptionValueInterface -{ - use TranslatableTrait { - __construct as private initializeTranslationCollection; - } - - /** - * @var mixed - */ - protected $id; - - /** - * @var string - */ - protected $code; - - /** - * @var string - */ - protected $value; - - /** - * @var OptionInterface - */ - protected $option; - - public function __construct() - { - $this->initializeTranslationCollection(); - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - return $this->getValue(); - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getCode() - { - return $this->code; - } - - /** - * {@inheritdoc} - */ - public function setCode($code) - { - $this->code = $code; - } - - /** - * {@inheritdoc} - */ - public function getOption() - { - return $this->option; - } - - /** - * {@inheritdoc} - */ - public function setOption(OptionInterface $option = null) - { - $this->option = $option; - } - - /** - * {@inheritdoc} - */ - public function getValue() - { - return $this->translate()->getValue(); - } - - /** - * {@inheritdoc} - */ - public function setValue($value) - { - $this->translate()->setValue($value); - } - - /** - * {@inheritdoc} - */ - public function getOptionCode() - { - if (null === $this->option) { - throw new \BadMethodCallException('The option have not been created yet so you cannot access proxy methods.'); - } - - return $this->option->getCode(); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - if (null === $this->option) { - throw new \BadMethodCallException('The option have not been created yet so you cannot access proxy methods.'); - } - - return $this->option->getName(); - } -} diff --git a/src/Sylius/Component/Variation/Model/OptionValueInterface.php b/src/Sylius/Component/Variation/Model/OptionValueInterface.php deleted file mode 100644 index d865edbb68..0000000000 --- a/src/Sylius/Component/Variation/Model/OptionValueInterface.php +++ /dev/null @@ -1,60 +0,0 @@ - - */ -interface OptionValueInterface extends ResourceInterface, CodeAwareInterface, TranslatableInterface -{ - /** - * @return OptionInterface - */ - public function getOption(); - - /** - * @param OptionInterface $option - */ - public function setOption(OptionInterface $option = null); - - /** - * Get internal value. - * - * @return string - */ - public function getValue(); - - /** - * Set internal value. - * - * @param string $value - */ - public function setValue($value); - - /** - * Proxy method to access the presentation of real option object. - * - * @return string The code of object - */ - public function getOptionCode(); - - /** - * Proxy method to access the name of real option object. - * - * @return string The name of object - */ - public function getName(); -} diff --git a/src/Sylius/Component/Variation/Model/OptionValueTranslation.php b/src/Sylius/Component/Variation/Model/OptionValueTranslation.php deleted file mode 100644 index b83c236196..0000000000 --- a/src/Sylius/Component/Variation/Model/OptionValueTranslation.php +++ /dev/null @@ -1,54 +0,0 @@ - - */ -class OptionValueTranslation extends AbstractTranslation implements OptionValueTranslationInterface -{ - /** - * @var mixed - */ - protected $id; - - /** - * @var string - */ - protected $value; - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getValue() - { - return $this->value; - } - - /** - * {@inheritdoc} - */ - public function setValue($value) - { - $this->value = $value; - } -} diff --git a/src/Sylius/Component/Variation/Model/OptionValueTranslationInterface.php b/src/Sylius/Component/Variation/Model/OptionValueTranslationInterface.php deleted file mode 100644 index d1a120020d..0000000000 --- a/src/Sylius/Component/Variation/Model/OptionValueTranslationInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - */ -interface OptionValueTranslationInterface extends ResourceInterface -{ - /** - * The name displayed to user. - * - * @return string - */ - public function getValue(); - - /** - * @param string $value - */ - public function setValue($value); -} diff --git a/src/Sylius/Component/Variation/Model/VariableInterface.php b/src/Sylius/Component/Variation/Model/VariableInterface.php deleted file mode 100644 index f3253a110f..0000000000 --- a/src/Sylius/Component/Variation/Model/VariableInterface.php +++ /dev/null @@ -1,86 +0,0 @@ - - */ -interface VariableInterface -{ - /** - * @return bool - */ - public function hasVariants(); - - /** - * @return Collection|VariantInterface[] - */ - public function getVariants(); - - /** - * @param Collection $variants - */ - public function setVariants(Collection $variants); - - /** - * @param VariantInterface $variant - */ - public function addVariant(VariantInterface $variant); - - /** - * @param VariantInterface $variant - */ - public function removeVariant(VariantInterface $variant); - - /** - * @param VariantInterface $variant - * - * @return bool - */ - public function hasVariant(VariantInterface $variant); - - /** - * @return bool - */ - public function hasOptions(); - - /** - * @return Collection|OptionInterface[] - */ - public function getOptions(); - - /** - * @param Collection $options - */ - public function setOptions(Collection $options); - - /** - * @param OptionInterface $option - */ - public function addOption(OptionInterface $option); - - /** - * @param OptionInterface $option - */ - public function removeOption(OptionInterface $option); - - /** - * @param OptionInterface $option - * - * @return bool - */ - public function hasOption(OptionInterface $option); -} diff --git a/src/Sylius/Component/Variation/Model/Variant.php b/src/Sylius/Component/Variation/Model/Variant.php deleted file mode 100644 index b02a8e3df5..0000000000 --- a/src/Sylius/Component/Variation/Model/Variant.php +++ /dev/null @@ -1,155 +0,0 @@ - - */ -class Variant implements VariantInterface -{ - use TimestampableTrait; - - /** - * @var mixed - */ - protected $id; - - /** - * @var string - */ - protected $code; - - /** - * @var string - */ - protected $name; - - /** - * @var VariableInterface - */ - protected $object; - - /** - * @var Collection|OptionValueInterface[] - */ - protected $options; - - public function __construct() - { - $this->options = new ArrayCollection(); - $this->createdAt = new \DateTime(); - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * @param string $code - */ - public function setCode($code) - { - $this->code = $code; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * {@inheritdoc} - */ - public function getObject() - { - return $this->object; - } - - /** - * {@inheritdoc} - */ - public function setObject(VariableInterface $object = null) - { - $this->object = $object; - } - - /** - * {@inheritdoc} - */ - public function getOptions() - { - return $this->options; - } - - /** - * {@inheritdoc} - */ - public function setOptions(Collection $options) - { - $this->options = $options; - } - - /** - * {@inheritdoc} - */ - public function addOption(OptionValueInterface $option) - { - if (!$this->hasOption($option)) { - $this->options->add($option); - } - } - - /** - * {@inheritdoc} - */ - public function removeOption(OptionValueInterface $option) - { - if ($this->hasOption($option)) { - $this->options->removeElement($option); - } - } - - /** - * {@inheritdoc} - */ - public function hasOption(OptionValueInterface $option) - { - return $this->options->contains($option); - } -} diff --git a/src/Sylius/Component/Variation/Model/VariantInterface.php b/src/Sylius/Component/Variation/Model/VariantInterface.php deleted file mode 100644 index 518e79ebbb..0000000000 --- a/src/Sylius/Component/Variation/Model/VariantInterface.php +++ /dev/null @@ -1,73 +0,0 @@ - - */ -interface VariantInterface extends TimestampableInterface, ResourceInterface, CodeAwareInterface -{ - /** - * This should be generated from option values - * when no other is set. - * - * @return string - */ - public function getName(); - - /** - * @param string $name - */ - public function setName($name); - - /** - * @return VariableInterface - */ - public function getObject(); - - /** - * @param VariableInterface|null $object - */ - public function setObject(VariableInterface $object = null); - - /** - * @return Collection|OptionValueInterface[] - */ - public function getOptions(); - - /** - * @param Collection $options - */ - public function setOptions(Collection $options); - - /** - * @param OptionValueInterface $option - */ - public function addOption(OptionValueInterface $option); - - /** - * @param OptionValueInterface $option - */ - public function removeOption(OptionValueInterface $option); - - /** - * @param OptionValueInterface $option - * - * @return bool - */ - public function hasOption(OptionValueInterface $option); -} diff --git a/src/Sylius/Component/Variation/README.md b/src/Sylius/Component/Variation/README.md deleted file mode 100644 index b2856326c1..0000000000 --- a/src/Sylius/Component/Variation/README.md +++ /dev/null @@ -1,52 +0,0 @@ -Variation Component [![Build status...](https://secure.travis-ci.org/Sylius/Variation.png?branch=master)](http://travis-ci.org/Sylius/Variation) -=================== - -Modern business applications often need to provide a system for entity -options. For example, a Server can have multiple variants or a Product can be -available in different sizes and colors. - -Sylius Variation component contains basic models and architecture to handle -this functionality. - -Sylius ------- - -Modern ecommerce for PHP and Symfony2. Visit [Sylius.org](http://sylius.org). - -Documentation -------------- - -Documentation is available on [**docs.sylius.org**](http://docs.sylius.org/en/latest/components/Variation/index.html). - -Contributing ------------- - -All instructions for contributing to Sylius can be found in the [Contributing Guide](http://docs.sylius.org/en/latest/contributing/index.html). - -Support -------- - -If you have a question regarding the usage of this library, please ask on -[Stackoverflow](http://stackoverflow.com). You should use "sylius" -tag when posting and make sure to [browse existing questions](http://stackoverflow.com/questions/tagged/sylius). - -Sylius on Twitter ------------------ - -[Follow the official Sylius account on Twitter!](http://twitter.com/Sylius). - -Bug Tracking ------------- - -If you find a bug, please refer to the [Reporting a Bug](http://docs.sylius.org/en/latest/contributing/code/bugs.html) guide. - -MIT License ------------ - -License can be found [here](https://github.com/Sylius/Variation/blob/master/LICENSE). - -Authors -------- - -The component was originally created by [Paweł Jędrzejewski](http://pjedrzejewski.com). -See the list of [contributors](https://github.com/Sylius/Variation/contributors). diff --git a/src/Sylius/Component/Variation/composer.json b/src/Sylius/Component/Variation/composer.json deleted file mode 100644 index d0a70c442f..0000000000 --- a/src/Sylius/Component/Variation/composer.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "sylius/variation", - "type": "library", - "description": "Object variants and options management for PHP.", - "keywords": ["shop", "ecommerce", "products", "product", "options", "variants"], - "homepage": "http://sylius.org", - "license": "MIT", - "authors": [ - { - "name": "Paweł Jędrzejewski", - "homepage": "http://pjedrzejewski.com" - }, - { - "name": "Sylius project", - "homepage": "http://sylius.org" - }, - { - "name": "Community contributions", - "homepage": "http://github.com/Sylius/Sylius/contributors" - } - ], - "require": { - "php": "^5.6|^7.0", - - "sylius/resource": "^1.0" - }, - "require-dev": { - "phpspec/phpspec": "^3.0" - }, - "config": { - "bin-dir": "bin" - }, - "autoload": { - "psr-4": { "Sylius\\Component\\Variation\\": "" } - }, - "autoload-dev": { - "psr-4": { "Sylius\\Component\\Variation\\spec\\": "spec/" } - }, - "minimum-stability": "dev", - "prefer-stable": true, - "repositories": [ - { - "type": "path", - "url": "../../*/*" - } - ], - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - } -} diff --git a/src/Sylius/Component/Variation/phpspec.yml.dist b/src/Sylius/Component/Variation/phpspec.yml.dist deleted file mode 100644 index 0dd6552ab7..0000000000 --- a/src/Sylius/Component/Variation/phpspec.yml.dist +++ /dev/null @@ -1,5 +0,0 @@ -suites: - main: - namespace: Sylius\Component\Variation - psr4_prefix: Sylius\Component\Variation - src_path: . diff --git a/src/Sylius/Component/Variation/spec/Model/OptionSpec.php b/src/Sylius/Component/Variation/spec/Model/OptionSpec.php deleted file mode 100644 index b9ba32f18c..0000000000 --- a/src/Sylius/Component/Variation/spec/Model/OptionSpec.php +++ /dev/null @@ -1,103 +0,0 @@ - - */ -final class OptionSpec extends ObjectBehavior -{ - public function let() - { - $this->setCurrentLocale('en_US'); - $this->setFallbackLocale('en_US'); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Component\Variation\Model\Option'); - } - - function it_implement_Sylius_option_interface() - { - $this->shouldImplement(OptionInterface::class); - } - - function it_should_not_have_id_by_default() - { - $this->getId()->shouldReturn(null); - } - - function it_has_mutable_code() - { - $this->setCode('O1'); - $this->getCode()->shouldReturn('O1'); - } - - function it_should_not_have_name_by_default() - { - $this->getName()->shouldReturn(null); - } - - function its_name_should_be_mutable() - { - $this->setName('Size'); - $this->getName()->shouldReturn('Size'); - } - - function it_returns_name_when_converted_to_string() - { - $this->setName('T-Shirt color'); - $this->__toString()->shouldReturn('T-Shirt color'); - } - - function it_should_initialize_values_collection_by_default() - { - $this->getValues()->shouldHaveType(Collection::class); - } - - function it_should_add_value(OptionValueInterface $value) - { - $value->setOption($this)->shouldBeCalled(); - - $this->addValue($value); - $this->hasValue($value)->shouldReturn(true); - } - - function it_should_remove_value(OptionValueInterface $value) - { - $value->setOption($this)->shouldBeCalled(); - - $this->addValue($value); - $this->hasValue($value)->shouldReturn(true); - - $value->setOption(null)->shouldBeCalled(); - - $this->removeValue($value); - $this->hasValue($value)->shouldReturn(false); - } - - function it_should_initialize_creation_date_by_default() - { - $this->getCreatedAt()->shouldHaveType(\DateTime::class); - } - - function it_should_not_have_last_update_date_by_default() - { - $this->getUpdatedAt()->shouldReturn(null); - } -} diff --git a/src/Sylius/Component/Variation/spec/Model/OptionTranslationSpec.php b/src/Sylius/Component/Variation/spec/Model/OptionTranslationSpec.php deleted file mode 100644 index b2fa3fc7f5..0000000000 --- a/src/Sylius/Component/Variation/spec/Model/OptionTranslationSpec.php +++ /dev/null @@ -1,47 +0,0 @@ - - */ -final class OptionTranslationSpec extends ObjectBehavior -{ - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Component\Variation\Model\OptionTranslation'); - } - - function it_implement_Sylius_option_interface() - { - $this->shouldImplement(OptionTranslationInterface::class); - } - - function it_should_not_have_id_by_default() - { - $this->getId()->shouldReturn(null); - } - - function it_should_not_have_name_by_default() - { - $this->getName()->shouldReturn(null); - } - - function its_name_should_be_mutable() - { - $this->setName('Size'); - $this->getName()->shouldReturn('Size'); - } -} diff --git a/src/Sylius/Component/Variation/spec/Model/OptionValueSpec.php b/src/Sylius/Component/Variation/spec/Model/OptionValueSpec.php deleted file mode 100644 index 9d0c32f8de..0000000000 --- a/src/Sylius/Component/Variation/spec/Model/OptionValueSpec.php +++ /dev/null @@ -1,121 +0,0 @@ - - */ -final class OptionValueSpec extends ObjectBehavior -{ - public function let() - { - $this->setCurrentLocale('en_US'); - $this->setFallbackLocale('en_US'); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Component\Variation\Model\OptionValue'); - } - - function it_is_a_Sylius_product_option_value() - { - $this->shouldImplement(OptionValueInterface::class); - } - - function it_should_not_have_id_by_default() - { - $this->getId()->shouldReturn(null); - } - - function it_has_mutable_code() - { - $this->setCode('OV1'); - $this->getCode()->shouldReturn('OV1'); - } - - function it_should_not_belong_to_an_option_by_default() - { - $this->getOption()->shouldReturn(null); - } - - function it_should_allow_assigning_itself_to_an_option(OptionInterface $option) - { - $this->setOption($option); - $this->getOption()->shouldReturn($option); - } - - function it_should_allow_detaching_itself_from_an_option(OptionInterface $option) - { - $this->setOption($option); - $this->getOption()->shouldReturn($option); - - $this->setOption(null); - $this->getOption()->shouldReturn(null); - } - - function it_should_not_have_value_by_default() - { - $this->getValue()->shouldReturn(null); - } - - function its_value_should_be_mutable() - { - $this->setValue('XXL'); - $this->getValue()->shouldReturn('XXL'); - } - - function it_returns_its_value_when_converted_to_string() - { - $this->setValue('S'); - $this->__toString()->shouldReturn('S'); - } - - function it_throws_exception_when_trying_to_get_option_code_without_option_being_assigned() - { - $this - ->shouldThrow(\BadMethodCallException::class) - ->duringGetOptionCode() - ; - } - - function it_returns_its_option_code(OptionInterface $option) - { - $option->getCode()->willReturn('01'); - $this->setOption($option); - - $this->getOptionCode()->shouldReturn('01'); - } - - function it_throws_exception_when_trying_to_get_name_without_option_being_assigned() - { - $this - ->shouldThrow(\BadMethodCallException::class) - ->during('getName') - ; - } - - function it_returns_its_option_name(OptionInterface $option) - { - $option->getName()->willReturn('Size'); - $this->setOption($option); - - $this->getName()->shouldReturn('Size'); - } -} diff --git a/src/Sylius/Component/Variation/spec/Model/VariantSpec.php b/src/Sylius/Component/Variation/spec/Model/VariantSpec.php deleted file mode 100644 index fa79b66fde..0000000000 --- a/src/Sylius/Component/Variation/spec/Model/VariantSpec.php +++ /dev/null @@ -1,106 +0,0 @@ - - */ -final class VariantSpec extends ObjectBehavior -{ - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Component\Variation\Model\Variant'); - } - - function it_implements_Sylius_variant_interface() - { - $this->shouldImplement(VariantInterface::class); - } - - function it_should_not_have_id_by_default() - { - $this->getId()->shouldReturn(null); - } - - function it_should_not_belong_to_a_variable_by_default() - { - $this->getObject()->shouldReturn(null); - } - - function it_should_allow_assigning_itself_to_a_variable(VariableInterface $variable) - { - $this->setObject($variable); - $this->getObject()->shouldReturn($variable); - } - - function it_should_allow_detaching_itself_from_a_variable(VariableInterface $variable) - { - $this->setObject($variable); - $this->getObject()->shouldReturn($variable); - - $this->setObject(null); - $this->getObject()->shouldReturn(null); - } - - function it_should_not_have_name_by_default() - { - $this->getName()->shouldReturn(null); - } - - function its_name_should_be_mutable() - { - $this->setName('Super variant'); - $this->getName()->shouldReturn('Super variant'); - } - - function it_should_initialize_option_values_collection_by_default() - { - $this->getOptions()->shouldHaveType('Doctrine\Common\Collections\Collection'); - } - - function its_option_values_collection_should_be_mutable(Collection $options) - { - $this->setOptions($options); - $this->getOptions()->shouldReturn($options); - } - - function it_should_add_option_value_properly(OptionValueInterface $option) - { - $this->addOption($option); - $this->hasOption($option)->shouldReturn(true); - } - - function it_should_remove_option_value_properly(OptionValueInterface $option) - { - $this->addOption($option); - $this->hasOption($option)->shouldReturn(true); - - $this->removeOption($option); - $this->hasOption($option)->shouldReturn(false); - } - - function it_should_initialize_creation_date_by_default() - { - $this->getCreatedAt()->shouldHaveType('DateTime'); - } - - function it_should_not_have_last_update_date_by_default() - { - $this->getUpdatedAt()->shouldReturn(null); - } -}