diff --git a/UPGRADE.md b/UPGRADE.md index 87571aa31c..fbcb45683c 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -7,6 +7,15 @@ UPGRADE * Renamed configuration option `sylius_channel.fake_channel_support` to `sylius_channel.debug` +### Order and OrderBundle + +* Added ``OrderSequence`` model to keep current order index +* Added ``OrderNumberGenerator`` to generate number for new orders + +### Sequence and SequenceBundle + +* Removed ``Sequence`` component and ``SequenceBundle`` + ## From 0.18 to 0.19.x ### Core and CoreBundle diff --git a/composer.json b/composer.json index a4685e6635..a48e901a6d 100644 --- a/composer.json +++ b/composer.json @@ -148,8 +148,6 @@ "sylius/resource": "self.version", "sylius/resource-bundle": "self.version", "sylius/search-bundle": "self.version", - "sylius/sequence": "self.version", - "sylius/sequence-bundle": "self.version", "sylius/settings-bundle": "self.version", "sylius/shipping": "self.version", "sylius/shipping-bundle": "self.version", diff --git a/composer.lock b/composer.lock index 4a513bdfb4..d78a032ad8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "3933e4fcbb56494b6df69eee8a0022b2", - "content-hash": "66eedeb56cc54d23081335ddf8ca3b7c", + "hash": "4b3521f709bb0a1eabbc87d7c3f8c0b4", "packages": [ { "name": "behat/transliterator", @@ -1839,7 +1838,6 @@ "rest", "web service" ], - "abandoned": "guzzlehttp/guzzle", "time": "2015-03-18 18:23:50" }, { @@ -6082,9 +6080,9 @@ ], "authors": [ { - "name": "Johannes Schmitt", + "name": "Johannes M. Schmitt", "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", + "homepage": "http://jmsyst.com", "role": "Developer of wrapped JMSSerializerBundle" } ], @@ -8759,7 +8757,7 @@ ], "authors": [ { - "name": "William Durand", + "name": "William DURAND", "email": "william.durand1@gmail.com", "homepage": "http://www.willdurand.fr" } @@ -10076,7 +10074,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Lakion/ApiTestCase/zipball/c4d37eccbaa49f06a317d22198649517627ed599", + "url": "https://api.github.com/repos/Lakion/ApiTestCase/zipball/171e6b7c00bc0d5b56edfc68f1a1d91f48c60850", "reference": "c4d37eccbaa49f06a317d22198649517627ed599", "shasum": "" }, @@ -10668,8 +10666,7 @@ "authors": [ { "name": "Chris Boulton", - "homepage": "http://github.com/chrisboulton", - "role": "Original developer" + "homepage": "http://github.com/chrisboulton" } ], "description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).", diff --git a/docs/components/Order/interfaces.rst b/docs/components/Order/interfaces.rst index 3f595e5f6f..b8a55442ac 100644 --- a/docs/components/Order/interfaces.rst +++ b/docs/components/Order/interfaces.rst @@ -16,8 +16,7 @@ This interface should be implemented by model representing a single Order. .. note:: This interface extends :ref:`component_resource_model_timestampable-interface`, :ref:`component_resource_model_timestampable-interface`, - :ref:`component_order_model_adjustable-interface`, :ref:`component_order_model_comment-aware-interface` - and :ref:`component_sequence_model_sequence-subject-interface`. + :ref:`component_order_model_adjustable-interface` and :ref:`component_order_model_comment-aware-interface` For more detailed information go to `Sylius API OrderInterface`_. @@ -148,8 +147,7 @@ In order to decouple from storage that provides recently completed orders or che you should create repository class which implements this interface. .. note:: - This interface extends the :ref:`component_resource_repository_repository-interface` and - the :ref:`component_sequence_repository_hash-subject-repository-interface`. + This interface extends the :ref:`component_resource_repository_repository-interface`. For more detailed information about the interface go to `Sylius API OrderRepositoryInterface`_. diff --git a/docs/components/Sequence/basic_usage.rst b/docs/components/Sequence/basic_usage.rst deleted file mode 100644 index c82953fc7e..0000000000 --- a/docs/components/Sequence/basic_usage.rst +++ /dev/null @@ -1,84 +0,0 @@ -Basic Usage -=========== - -In order to benefit from the component's features at first you need to create a basic class that will implement -the :ref:`component_sequence_model_sequence-subject-interface`. Let's assume that you would like to generate identifiers for orders in your system. Your **Order** class therefore will implement this interface -to have and ability to be a subject of sequence automatic generation by your services. - -SequenceSubjectInterface ------------------------- - -Let's see how an exemplary class implementing **SequenceSubjectInterface** should look like. - -.. code-block:: php - - number; - } - - /** - * {@inheritdoc} - */ - public function setNumber($number) - { - $this->number = $number; - } - } - -.. _component_sequence_number_sequential-generator-usage: - -Let's now see how we can use an exemplary generator: - -.. code-block:: php - - generate($subject, $sequence); - $generator->generate($anotherSubject, $sequence); - - $subject->getNumber(); // returns '0077' - $anotherSubject->getNumber(); // returns '0078' - -.. hint:: - - You can read more about each of the available generators in the :doc:`generators` chapter. diff --git a/docs/components/Sequence/generators.rst b/docs/components/Sequence/generators.rst deleted file mode 100644 index 9093087932..0000000000 --- a/docs/components/Sequence/generators.rst +++ /dev/null @@ -1,114 +0,0 @@ -Generators -========== - -.. _component_sequence_number_abstract-generator: - -AbstractGenerator ------------------ - -A custom generator model should extend this class in order to generate sequences -on a given object that implements the :ref:`component_sequence_model_sequence-subject-interface`. - -.. note:: - This class implements the :ref:`component_sequence_number_generator-interface`. - - For more detailed information go to `Sylius API AbstractGenerator`_. - -.. _Sylius API AbstractGenerator: http://api.sylius.org/Sylius/Component/Sequence/Number/AbstractGenerator.html - -.. _component_sequence_number_sequential-generator: - -SequentialGenerator -------------------- - -This class is a default order number generator. - -+--------------------+------------------------------+ -| Property | Description | -+====================+==============================+ -| numberLength | Order number max length | -+--------------------+------------------------------+ -| startNumber | The sequence start number | -+--------------------+------------------------------+ - -Below you can see a snippet on how to use it: - -.. code-block:: php - - generate($subject, $sequence); // generates '0077' - $generator->generate($anotherSubject, $sequence); // generates '0078' - -.. note:: - This generator implements the :ref:`component_sequence_number_generator-interface` - and extends the :ref:`component_sequence_number_abstract-generator`. - - For more detailed information go to `Sylius API SequentialGenerator`_. - -.. _Sylius API SequentialGenerator: http://api.sylius.org/Sylius/Component/Sequence/Number/SequentialGenerator.html - -.. _component_sequence_number_hash-generator: - -HashGenerator -------------- - -This class generates hash numbers similar to the Amazon order identifiers (e.g. 105-3958356-3707476) -and also random hashed segments of a given length. - - Below you can see a snippet on how to use it: - -.. code-block:: php - - generateNumber($index, $subject); - - $subject->getNumber(); // returns randomized sequence of format 'xxx-xxxxxxx-xxxxxxx' - -.. note:: - This generator implements the :ref:`component_sequence_number_generator-interface` - and extends the :ref:`component_sequence_number_abstract-generator`. - - For more detailed information go to `Sylius API HashGenerator`_. - -.. _Sylius API HashGenerator: http://api.sylius.org/Sylius/Component/Sequence/Number/HashGenerator.html - -.. _component_sequence_registry_generator-registry: - -GeneratorRegistry ------------------ - -It returns the generator used for a given entity. - -.. note:: - This service extends the :ref:`component_registry_service-registry`. - - For more detailed information go to `Sylius API GeneratorRegistry`_. - -.. caution:: - Throws :ref:`component_registry_non-existing-service-exception`. - -.. _Sylius API GeneratorRegistry: http://api.sylius.org/Sylius/Component/Sequence/Registry/GeneratorRegistry.html - -.. _component_sequence_generator_non-existing-generator-exception: - -NonExistingGeneratorException ------------------------------ - -This exception is thrown when your are trying to get a generator that does not exist in your system. - -.. note:: This exception extends the `\\InvalidArgumentException`_. - -.. _\\InvalidArgumentException: http://php.net/manual/en/class.invalidargumentexception.php diff --git a/docs/components/Sequence/index.rst b/docs/components/Sequence/index.rst deleted file mode 100644 index 5f9620e7bb..0000000000 --- a/docs/components/Sequence/index.rst +++ /dev/null @@ -1,13 +0,0 @@ -Sequence -======== - -Component for generating number/hash sequences in PHP. - -.. toctree:: - :maxdepth: 2 - - installation - basic_usage - models - interfaces - generators \ No newline at end of file diff --git a/docs/components/Sequence/installation.rst b/docs/components/Sequence/installation.rst deleted file mode 100644 index dd0ca4c4bc..0000000000 --- a/docs/components/Sequence/installation.rst +++ /dev/null @@ -1,11 +0,0 @@ -Installation -============ - -You can install the component in 2 different ways: - -* :doc:`Install it via Composer ` (``sylius/sequence`` on `Packagist`_); -* Use the official Git repository (https://github.com/Sylius/Sequence). - -.. include:: /components/require_autoload.rst.inc - -.. _Packagist: https://packagist.org/packages/sylius/sequence diff --git a/docs/components/Sequence/interfaces.rst b/docs/components/Sequence/interfaces.rst deleted file mode 100644 index d8e90b2cc4..0000000000 --- a/docs/components/Sequence/interfaces.rst +++ /dev/null @@ -1,60 +0,0 @@ -Interfaces -========== - -Model Interfaces ----------------- - -.. _component_sequence_model_sequence-interface: - -SequenceInterface -~~~~~~~~~~~~~~~~~ - -This interface should be implemented by models representing a **Sequence**. - -.. note:: - - You will find more information about this interface in `Sylius API SequenceInterface`_. - -.. _Sylius API SequenceInterface: http://api.sylius.org/Sylius/Component/Sequence/Model/SequenceInterface.html - -.. _component_sequence_model_sequence-subject-interface: - -SequenceSubjectInterface -~~~~~~~~~~~~~~~~~~~~~~~~ - -To characterize an object with attributes and options from a sequence, the object class needs to implement the ``SequenceSubjectInterface``. - -.. note:: - - You will find more information about this interface in `Sylius API SequenceSubjectInterface`_. - -.. _Sylius API SequenceSubjectInterface: http://api.sylius.org/Sylius/Component/Sequence/Model/SequenceSubjectInterface.html - -Service Interfaces ------------------- - -.. _component_sequence_number_generator-interface: - -GeneratorInterface -~~~~~~~~~~~~~~~~~~ - -This interface gives a possibility to generate and apply next available number for a given subject. - -.. note:: - - You will find more information about this interface in `Sylius API GeneratorInterface`_. - -.. _Sylius API GeneratorInterface: http://api.sylius.org/Sylius/Component/Sequence/Number/GeneratorInterface.html - -.. _component_sequence_repository_hash-subject-repository-interface: - -HashSubjectRepositoryInterface -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Repository interface for model which needs number uniqueness check before applying. It provides a method ``isNumberUsed()``. - -.. note:: - - You will find more information about this interface in `Sylius API HashSubjectRepositoryInterface`_. - -.. _Sylius API HashSubjectRepositoryInterface: http://api.sylius.org/Sylius/Component/Sequence/Repository/HashSubjectRepositoryInterface.html diff --git a/docs/components/Sequence/models.rst b/docs/components/Sequence/models.rst deleted file mode 100644 index f6220c99cf..0000000000 --- a/docs/components/Sequence/models.rst +++ /dev/null @@ -1,26 +0,0 @@ -Models -====== - -.. _component_sequence_model_sequence: - -Sequence --------- - -**Sequence** is a generated set of numbers and/or letters stored on a model. They may be useful for example as order or customer identifiers. - -+------------+------------------------------+ -| Property | Description | -+============+==============================+ -| id | Unique id of the sequence | -+------------+------------------------------+ -| index | The sequence's index | -+------------+------------------------------+ -| type | The sequence's type | -+------------+------------------------------+ - -.. note:: - This model implements the :ref:`component_sequence_model_sequence-interface`. - - For more detailed information go to `Sylius API Sequence`_. - -.. _Sylius API Sequence: http://api.sylius.org/Sylius/Component/Sequence/Model/Sequence.html diff --git a/docs/components/index.rst b/docs/components/index.rst index b9a78cdbc7..2422952b2f 100644 --- a/docs/components/index.rst +++ b/docs/components/index.rst @@ -35,7 +35,6 @@ We recommend checking out :doc:`/components/general/index`, which will get you s Registry/index Report/index Resource/index - Sequence/index Shipping/index Storage/index Taxation/index diff --git a/docs/components/map.rst.inc b/docs/components/map.rst.inc index cf38b75121..05337130db 100644 --- a/docs/components/map.rst.inc +++ b/docs/components/map.rst.inc @@ -20,7 +20,6 @@ * :doc:`/components/Registry/index` * :doc:`/components/Report/index` * :doc:`/components/Resource/index` -* :doc:`/components/Sequence/index` * :doc:`/components/Shipping/index` * :doc:`/components/Storage/index` * :doc:`/components/Taxation/index` diff --git a/phpspec.yml.dist b/phpspec.yml.dist index 90426b995d..91a07f3b50 100644 --- a/phpspec.yml.dist +++ b/phpspec.yml.dist @@ -24,7 +24,6 @@ suites: Report: { namespace: Sylius\Component\Report, psr4_prefix: Sylius\Component\Report, spec_path: src/Sylius/Component/Report, src_path: src/Sylius/Component/Report } Resource: { namespace: Sylius\Component\Resource, psr4_prefix: Sylius\Component\Resource, spec_path: src/Sylius/Component/Resource, src_path: src/Sylius/Component/Resource } Review: { namespace: Sylius\Component\Review, psr4_prefix: Sylius\Component\Review, spec_path: src/Sylius/Component/Review, src_path: src/Sylius/Component/Review } - Sequence: { namespace: Sylius\Component\Sequence, psr4_prefix: Sylius\Component\Sequence, spec_path: src/Sylius/Component/Sequence, src_path: src/Sylius/Component/Sequence } Shipping: { namespace: Sylius\Component\Shipping, psr4_prefix: Sylius\Component\Shipping, spec_path: src/Sylius/Component/Shipping, src_path: src/Sylius/Component/Shipping } Storage: { namespace: Sylius\Component\Storage, psr4_prefix: Sylius\Component\Storage, spec_path: src/Sylius/Component/Storage, src_path: src/Sylius/Component/Storage } Taxation: { namespace: Sylius\Component\Taxation, psr4_prefix: Sylius\Component\Taxation, spec_path: src/Sylius/Component/Taxation, src_path: src/Sylius/Component/Taxation } @@ -64,7 +63,6 @@ suites: ResourceBundle: { namespace: Sylius\Bundle\ResourceBundle, psr4_prefix: Sylius\Bundle\ResourceBundle, spec_path: src/Sylius/Bundle/ResourceBundle, src_path: src/Sylius/Bundle/ResourceBundle } ReviewBundle: { namespace: Sylius\Bundle\ReviewBundle, psr4_prefix: Sylius\Bundle\ReviewBundle, spec_path: src/Sylius/Bundle/ReviewBundle, src_path: src/Sylius/Bundle/ReviewBundle } SearchBundle: { namespace: Sylius\Bundle\SearchBundle, psr4_prefix: Sylius\Bundle\SearchBundle, spec_path: src/Sylius/Bundle/SearchBundle, src_path: src/Sylius/Bundle/SearchBundle } - SequenceBundle: { namespace: Sylius\Bundle\SequenceBundle, psr4_prefix: Sylius\Bundle\SequenceBundle, spec_path: src/Sylius/Bundle/SequenceBundle, src_path: src/Sylius/Bundle/SequenceBundle } SettingsBundle: { namespace: Sylius\Bundle\SettingsBundle, psr4_prefix: Sylius\Bundle\SettingsBundle, spec_path: src/Sylius/Bundle/SettingsBundle, src_path: src/Sylius/Bundle/SettingsBundle } ShippingBundle: { namespace: Sylius\Bundle\ShippingBundle, psr4_prefix: Sylius\Bundle\ShippingBundle, spec_path: src/Sylius/Bundle/ShippingBundle, src_path: src/Sylius/Bundle/ShippingBundle } ShopBundle: { namespace: Sylius\Bundle\ShopBundle, psr4_prefix: Sylius\Bundle\ShopBundle, spec_path: src/Sylius/Bundle/ShopBundle, src_path: src/Sylius/Bundle/ShopBundle } diff --git a/src/Sylius/Bundle/CoreBundle/Application/Kernel.php b/src/Sylius/Bundle/CoreBundle/Application/Kernel.php index aac7e9c4a4..e3b7418871 100644 --- a/src/Sylius/Bundle/CoreBundle/Application/Kernel.php +++ b/src/Sylius/Bundle/CoreBundle/Application/Kernel.php @@ -58,7 +58,6 @@ class Kernel extends HttpKernel new \Sylius\Bundle\TaxonomyBundle\SyliusTaxonomyBundle(), new \Sylius\Bundle\FlowBundle\SyliusFlowBundle(), new \Sylius\Bundle\PricingBundle\SyliusPricingBundle(), - new \Sylius\Bundle\SequenceBundle\SyliusSequenceBundle(), new \Sylius\Bundle\ContentBundle\SyliusContentBundle(), new \Sylius\Bundle\RbacBundle\SyliusRbacBundle(), new \Sylius\Bundle\UserBundle\SyliusUserBundle(), diff --git a/src/Sylius/Bundle/CoreBundle/DependencyInjection/SyliusCoreExtension.php b/src/Sylius/Bundle/CoreBundle/DependencyInjection/SyliusCoreExtension.php index 5bf143b10a..2edd37229b 100644 --- a/src/Sylius/Bundle/CoreBundle/DependencyInjection/SyliusCoreExtension.php +++ b/src/Sylius/Bundle/CoreBundle/DependencyInjection/SyliusCoreExtension.php @@ -46,7 +46,6 @@ class SyliusCoreExtension extends AbstractResourceExtension implements PrependEx 'sylius_promotion', 'sylius_review', 'sylius_report', - 'sylius_sequence', 'sylius_settings', 'sylius_shipping', 'sylius_mailer', diff --git a/src/Sylius/Bundle/OrderBundle/Resources/config/app/config.yml b/src/Sylius/Bundle/OrderBundle/Resources/config/app/config.yml index 6c3558d777..7ad3232b08 100644 --- a/src/Sylius/Bundle/OrderBundle/Resources/config/app/config.yml +++ b/src/Sylius/Bundle/OrderBundle/Resources/config/app/config.yml @@ -10,7 +10,3 @@ jms_serializer: sylius-order: namespace_prefix: "Sylius\\Component\\Order" path: "@SyliusOrderBundle/Resources/config/serializer" - -sylius_sequence: - generators: - "%sylius.model.order.class%": sylius.sequence.sequential_number_generator diff --git a/src/Sylius/Bundle/OrderBundle/composer.json b/src/Sylius/Bundle/OrderBundle/composer.json index e2c2ed78ed..d4afde88b4 100644 --- a/src/Sylius/Bundle/OrderBundle/composer.json +++ b/src/Sylius/Bundle/OrderBundle/composer.json @@ -26,7 +26,6 @@ "sylius/order": "^1.0", "sylius/money-bundle": "^1.0", "sylius/resource-bundle": "^1.0", - "sylius/sequence-bundle": "^1.0", "symfony/framework-bundle": "^2.8" }, "require-dev": { diff --git a/src/Sylius/Bundle/SequenceBundle/.gitignore b/src/Sylius/Bundle/SequenceBundle/.gitignore deleted file mode 100644 index 46aed33710..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -vendor/ -bin/ - -composer.phar -composer.lock diff --git a/src/Sylius/Bundle/SequenceBundle/CHANGELOG.md b/src/Sylius/Bundle/SequenceBundle/CHANGELOG.md deleted file mode 100644 index e7209ef157..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/CHANGELOG.md +++ /dev/null @@ -1,6 +0,0 @@ -CHANGELOG -========= - -### v0.10.0 - -* Initial dev release diff --git a/src/Sylius/Bundle/SequenceBundle/DependencyInjection/Compiler/RegisterGeneratorsPass.php b/src/Sylius/Bundle/SequenceBundle/DependencyInjection/Compiler/RegisterGeneratorsPass.php deleted file mode 100644 index 60f08c8650..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/DependencyInjection/Compiler/RegisterGeneratorsPass.php +++ /dev/null @@ -1,41 +0,0 @@ - - */ -class RegisterGeneratorsPass implements CompilerPassInterface -{ - /** - * {@inheritdoc} - */ - public function process(ContainerBuilder $container) - { - if (!$container->hasDefinition('sylius.registry.number_generator')) { - return; - } - - $generators = $container->getParameter('sylius.sequence.generators'); - $registry = $container->getDefinition('sylius.registry.number_generator'); - - foreach ($generators as $interface => $generator) { - $registry->addMethodCall('register', [$interface, new Reference($generator)]); - } - } -} diff --git a/src/Sylius/Bundle/SequenceBundle/DependencyInjection/Configuration.php b/src/Sylius/Bundle/SequenceBundle/DependencyInjection/Configuration.php deleted file mode 100644 index a1d2a83b2b..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/DependencyInjection/Configuration.php +++ /dev/null @@ -1,100 +0,0 @@ - - */ -class Configuration implements ConfigurationInterface -{ - /** - * {@inheritdoc} - */ - public function getConfigTreeBuilder() - { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('sylius_sequence'); - - $rootNode - ->addDefaultsIfNotSet() - ->children() - ->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end() - ->end() - ; - - $this->addResourcesSection($rootNode); - $this->addGeneratorsSection($rootNode); - - return $treeBuilder; - } - - /** - * @param ArrayNodeDefinition $node - */ - private function addResourcesSection(ArrayNodeDefinition $node) - { - $node - ->children() - ->arrayNode('resources') - ->addDefaultsIfNotSet() - ->children() - ->arrayNode('sequence') - ->addDefaultsIfNotSet() - ->children() - ->variableNode('options')->end() - ->arrayNode('classes') - ->addDefaultsIfNotSet() - ->children() - ->scalarNode('model')->defaultValue(Sequence::class)->cannotBeEmpty()->end() - ->scalarNode('interface')->defaultValue(SequenceInterface::class)->cannotBeEmpty()->end() - ->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() - ->scalarNode('repository')->cannotBeEmpty()->end() - ->scalarNode('factory')->defaultValue(Factory::class)->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ; - } - - /** - * @param ArrayNodeDefinition $node - */ - private function addGeneratorsSection(ArrayNodeDefinition $node) - { - $node - ->children() - ->arrayNode('generators') - ->useAttributeAsKey('interface') - ->prototype('scalar') - ->end() - ->end() - ; - } -} diff --git a/src/Sylius/Bundle/SequenceBundle/DependencyInjection/SyliusSequenceExtension.php b/src/Sylius/Bundle/SequenceBundle/DependencyInjection/SyliusSequenceExtension.php deleted file mode 100644 index f926bff990..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/DependencyInjection/SyliusSequenceExtension.php +++ /dev/null @@ -1,47 +0,0 @@ - - */ -class SyliusSequenceExtension extends AbstractResourceExtension -{ - /** - * {@inheritdoc} - */ - public function load(array $config, ContainerBuilder $container) - { - $config = $this->processConfiguration($this->getConfiguration($config, $container), $config); - $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - - $this->registerResources('sylius', $config['driver'], $config['resources'], $container); - - $configFiles = [ - 'services.xml', - sprintf('driver/%s.xml', $config['driver']), - ]; - - foreach ($configFiles as $configFile) { - $loader->load($configFile); - } - - $container->setParameter('sylius.sequence.generators', $config['generators']); - } -} diff --git a/src/Sylius/Bundle/SequenceBundle/Doctrine/ORM/NumberListener.php b/src/Sylius/Bundle/SequenceBundle/Doctrine/ORM/NumberListener.php deleted file mode 100644 index b00ee27f81..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/Doctrine/ORM/NumberListener.php +++ /dev/null @@ -1,155 +0,0 @@ - - * @author Saša Stamenković - */ -class NumberListener -{ - /** - * @var ServiceRegistryInterface - */ - protected $registry; - - /** - * @var EventManager - */ - protected $eventManager; - - /** - * @var EventDispatcherInterface - */ - protected $eventDispatcher; - - /** - * @var string - */ - protected $sequenceClass; - - /** - * @var SequenceSubjectInterface[] - */ - protected $entitiesEnabled = []; - - /** - * @var array - */ - protected $sequences = []; - - /** - * @var bool - */ - protected $listenerEnabled = false; - - /** - * @param ServiceRegistryInterface $registry - * @param EventManager $eventManager - * @param EventDispatcherInterface $eventDispatcher - * @param string $sequenceClass - */ - public function __construct( - ServiceRegistryInterface $registry, - EventManager $eventManager, - EventDispatcherInterface $eventDispatcher, - $sequenceClass - ) { - $this->registry = $registry; - $this->eventManager = $eventManager; - $this->eventDispatcher = $eventDispatcher; - $this->sequenceClass = $sequenceClass; - } - - /** - * {@inheritdoc} - */ - public function enableEntity(SequenceSubjectInterface $subject) - { - $this->entitiesEnabled[spl_object_hash($subject)] = $subject; - - if (!$this->listenerEnabled) { - $this->eventManager->addEventListener(Events::preFlush, $this); - $this->listenerEnabled = true; - } - } - - /** - * {@inheritdoc} - */ - public function preFlush(PreFlushEventArgs $args) - { - $em = $args->getEntityManager(); - - foreach ($this->entitiesEnabled as $entity) { - try { - $generator = $this->registry->get($entity); - } catch (NonExistingServiceException $e) { - throw new NonExistingGeneratorException($entity, $e); - } - - $sequence = $this->getSequence($entity->getSequenceType(), $em); - - $event = new GenericEvent($entity); - - $this->eventDispatcher->dispatch( - sprintf(SyliusSequenceEvents::PRE_GENERATE, $entity->getSequenceType()), - $event - ); - - $generator->generate($entity, $sequence); - - $this->eventDispatcher->dispatch( - sprintf(SyliusSequenceEvents::POST_GENERATE, $entity->getSequenceType()), - $event - ); - } - } - - /** - * @param string $type - * @param EntityManagerInterface $entityManager - * - * @return SequenceInterface - */ - protected function getSequence($type, EntityManagerInterface $entityManager) - { - if (isset($this->sequences[$type])) { - return $this->sequences[$type]; - } - - $sequence = $entityManager - ->getRepository($this->sequenceClass) - ->findOneBy(['type' => $type]) - ; - - if (null === $sequence) { - $sequence = new $this->sequenceClass($type); - $entityManager->persist($sequence); - } - - return $this->sequences[$type] = $sequence; - } -} diff --git a/src/Sylius/Bundle/SequenceBundle/README.md b/src/Sylius/Bundle/SequenceBundle/README.md deleted file mode 100644 index 0fdd648827..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/README.md +++ /dev/null @@ -1,74 +0,0 @@ -SyliusSequenceBundle [![Build status...](https://secure.travis-ci.org/Sylius/SyliusSequenceBundle.png?branch=master)](http://travis-ci.org/Sylius/SyliusSequenceBundle) -==================== - -Sequence system with web editing interface for [**Symfony2**](http://symfony.com) applications. - -Sylius ------- - -**Sylius** - Modern ecommerce for Symfony2. Visit [Sylius.org](http://sylius.org). - -[phpspec](http://phpspec.net) examples --------------------------------------- - -```bash -$ composer install -$ bin/phpspec run -f pretty -``` - -Documentation -------------- - -Documentation is available on [**docs.sylius.org**](http://docs.sylius.org/en/latest/bundles/SyliusSequenceBundle/index.html). - -Contributing ------------- - -All informations about contributing to Sylius can be found on [this page](http://docs.sylius.org/en/latest/contributing/index.html). - -Mailing lists -------------- - -### Users - -Questions? Feel free to ask on [users mailing list](http://groups.google.com/group/sylius). - -### Developers - -To contribute and develop this bundle, use the [developers mailing list](http://groups.google.com/group/sylius-dev). - -Sylius twitter account ----------------------- - -If you want to keep up with updates, [follow the official Sylius account on twitter](http://twitter.com/Sylius). - -Bug tracking ------------- - -This bundle uses [GitHub issues](https://github.com/Sylius/Sylius/issues). -If you have found bug, please create an issue. - -Versioning ----------- - -Releases will be numbered with the format `major.minor.patch`. - -And constructed with the following guidelines. - -* Breaking backwards compatibility bumps the major. -* New additions without breaking backwards compatibility bumps the minor. -* Bug fixes and misc changes bump the patch. - -For more information on SemVer, please visit [semver.org website](http://semver.org/). -This versioning method is same for all **Sylius** bundles and applications. - -MIT License ------------ - -License can be found [here](https://github.com/Sylius/SyliusSequenceBundle/blob/master/Resources/meta/LICENSE). - -Authors -------- - -The bundle was originally created by [Paweł Jędrzejewski](http://pjedrzejewski.com). -See the list of [contributors](https://github.com/Sylius/SyliusSequenceBundle/contributors). diff --git a/src/Sylius/Bundle/SequenceBundle/Resources/config/doctrine/model/Sequence.orm.xml b/src/Sylius/Bundle/SequenceBundle/Resources/config/doctrine/model/Sequence.orm.xml deleted file mode 100644 index d962ba6c30..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/Resources/config/doctrine/model/Sequence.orm.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/Sylius/Bundle/SequenceBundle/Resources/config/driver/doctrine/orm.xml b/src/Sylius/Bundle/SequenceBundle/Resources/config/driver/doctrine/orm.xml deleted file mode 100644 index 53bdd6d7e7..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/Resources/config/driver/doctrine/orm.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - Sylius\Bundle\SequenceBundle\Doctrine\ORM\NumberListener - - - - - - - - - - %sylius.model.sequence.class% - - - - diff --git a/src/Sylius/Bundle/SequenceBundle/Resources/config/services.xml b/src/Sylius/Bundle/SequenceBundle/Resources/config/services.xml deleted file mode 100644 index aee3f225e2..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/Resources/config/services.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - Sylius\Component\Sequence\Registry\GeneratorRegistry - - Sylius\Component\Sequence\Number\GeneratorInterface - - Sylius\Component\Sequence\Number\SequentialGenerator - Sylius\Component\Sequence\Number\HashGenerator - - - - - %sylius.sequence.number_generator.interface% - - - - - diff --git a/src/Sylius/Bundle/SequenceBundle/Resources/meta/LICENSE b/src/Sylius/Bundle/SequenceBundle/Resources/meta/LICENSE deleted file mode 100644 index acd4c1958c..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/Resources/meta/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/Bundle/SequenceBundle/SyliusSequenceBundle.php b/src/Sylius/Bundle/SequenceBundle/SyliusSequenceBundle.php deleted file mode 100644 index 7c7033f34d..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/SyliusSequenceBundle.php +++ /dev/null @@ -1,53 +0,0 @@ - - */ -class SyliusSequenceBundle extends AbstractResourceBundle -{ - /** - * {@inheritdoc} - */ - public function getSupportedDrivers() - { - return [ - SyliusResourceBundle::DRIVER_DOCTRINE_ORM, - ]; - } - - /** - * {@inheritdoc} - */ - public function build(ContainerBuilder $container) - { - parent::build($container); - - $container->addCompilerPass(new RegisterGeneratorsPass()); - } - - /** - * {@inheritdoc} - */ - protected function getModelNamespace() - { - return 'Sylius\Component\Sequence\Model'; - } -} diff --git a/src/Sylius/Bundle/SequenceBundle/composer.json b/src/Sylius/Bundle/SequenceBundle/composer.json deleted file mode 100644 index 02f2986b39..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/composer.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "sylius/sequence-bundle", - "type": "symfony-bundle", - "description": "Sequence system for Symfony2 applications.", - "keywords": ["config", "configuration", "sequence", "shop", "webshop", "ecommerce"], - "homepage": "http://sylius.org", - "license": "MIT", - "authors": [ - { - "name": "Paweł Jędrzejewski", - "homepage": "http://pjedrzejewski.com" - }, - { - "name": "Alexandre Bacco", - "homepage": "http://alex.bacco.fr" - }, - { - "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-bundle": "^1.0", - "sylius/sequence": "^1.0", - "symfony/framework-bundle": "^2.8" - }, - "require-dev": { - "phpspec/phpspec": "^2.4", - "doctrine/orm": "^2.4.8,<2.5" - }, - "config": { - "bin-dir": "bin" - }, - "autoload": { - "psr-4": { "Sylius\\Bundle\\SequenceBundle\\": "" } - }, - "autoload-dev": { - "psr-4": { "spec\\Sylius\\Bundle\\SequenceBundle\\": "spec/" } - }, - "minimum-stability": "dev", - "prefer-stable": true, - "repositories": [ - { - "type": "path", - "url": "../../*/*" - } - ], - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - } -} diff --git a/src/Sylius/Bundle/SequenceBundle/phpspec.yml.dist b/src/Sylius/Bundle/SequenceBundle/phpspec.yml.dist deleted file mode 100644 index 480ea57a33..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/phpspec.yml.dist +++ /dev/null @@ -1,5 +0,0 @@ -suites: - main: - namespace: Sylius\Bundle\SequenceBundle - psr4_prefix: Sylius\Bundle\SequenceBundle - src_path: . diff --git a/src/Sylius/Bundle/SequenceBundle/spec/DependencyInjection/Compiler/RegisterGeneratorsPassSpec.php b/src/Sylius/Bundle/SequenceBundle/spec/DependencyInjection/Compiler/RegisterGeneratorsPassSpec.php deleted file mode 100644 index 17a3da613f..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/spec/DependencyInjection/Compiler/RegisterGeneratorsPassSpec.php +++ /dev/null @@ -1,46 +0,0 @@ - - */ -class RegisterGeneratorsPassSpec extends ObjectBehavior -{ - public function it_is_initializable() - { - $this->shouldHaveType('Sylius\Bundle\SequenceBundle\DependencyInjection\Compiler\RegisterGeneratorsPass'); - } - - public function it_is_a_compiler_pass() - { - $this->shouldImplement(CompilerPassInterface::class); - } - - public function it_processes_the_calculators_services(ContainerBuilder $container, Definition $registry) - { - $container->hasDefinition('sylius.registry.number_generator')->shouldBeCalled()->willReturn(true); - $container->getDefinition('sylius.registry.number_generator')->shouldBeCalled()->willReturn($registry); - - $container->getParameter('sylius.sequence.generators')->shouldBeCalled()->willReturn(['generator']); - - $registry->addMethodCall('register', Argument::type('array'))->shouldBeCalled(); - - $this->process($container); - } -} diff --git a/src/Sylius/Bundle/SequenceBundle/spec/Doctrine/ORM/NumberListenerSpec.php b/src/Sylius/Bundle/SequenceBundle/spec/Doctrine/ORM/NumberListenerSpec.php deleted file mode 100644 index 4a73e9c0c9..0000000000 --- a/src/Sylius/Bundle/SequenceBundle/spec/Doctrine/ORM/NumberListenerSpec.php +++ /dev/null @@ -1,92 +0,0 @@ - - */ -class NumberListenerSpec extends ObjectBehavior -{ - function let( - ServiceRegistryInterface $registry, - EventManager $eventManager, - EventDispatcherInterface $eventDispatcher - ) { - $this->beConstructedWith( - $registry, - $eventManager, - $eventDispatcher, - Sequence::class - ); - } - - function it_enable_listener_on_specific_entity(SequenceSubjectInterface $subject, $eventManager) - { - $eventManager->addEventListener( - Events::preFlush, - Argument::type('Sylius\Bundle\SequenceBundle\Doctrine\ORM\NumberListener') - )->shouldBeCalled(); - - $this->enableEntity($subject); - } - - function it_applies_generator( - PreFlushEventArgs $args, - EntityManager $entityManager, - SequenceSubjectInterface $entity, - GeneratorInterface $generator, - EntityRepository $sequenceRepository, - Sequence $sequence, - $registry, - $eventDispatcher - ) { - $this->enableEntity($entity); - - $args->getEntityManager()->willReturn($entityManager); - - $registry->get($entity) - ->willReturn($generator); - - $entity->getSequenceType()->willReturn('sequence_type'); - - $entityManager->getRepository(Sequence::class)->willReturn($sequenceRepository); - $sequenceRepository->findOneBy(['type' => 'sequence_type'])->willReturn($sequence); - - $eventDispatcher->dispatch( - sprintf(SyliusSequenceEvents::PRE_GENERATE, 'sequence_type'), - Argument::type('Symfony\Component\EventDispatcher\GenericEvent') - )->shouldBeCalled(); - - $generator->generate($entity, $sequence)->shouldBeCalled(); - - $eventDispatcher->dispatch( - sprintf(SyliusSequenceEvents::POST_GENERATE, 'sequence_type'), - Argument::type('Symfony\Component\EventDispatcher\GenericEvent') - )->shouldBeCalled(); - - $this->preFlush($args); - } -} diff --git a/src/Sylius/Component/Core/composer.json b/src/Sylius/Component/Core/composer.json index 2bae72c964..6a821a657f 100644 --- a/src/Sylius/Component/Core/composer.json +++ b/src/Sylius/Component/Core/composer.json @@ -40,7 +40,6 @@ "sylius/rbac": "^1.0", "sylius/registry": "^1.0", "sylius/resource": "^1.0", - "sylius/sequence": "^1.0", "sylius/shipping": "^1.0", "sylius/storage": "^1.0", "sylius/taxation": "^1.0", diff --git a/src/Sylius/Component/Order/Model/Order.php b/src/Sylius/Component/Order/Model/Order.php index 9f641d424c..7aa35b6f60 100644 --- a/src/Sylius/Component/Order/Model/Order.php +++ b/src/Sylius/Component/Order/Model/Order.php @@ -166,14 +166,6 @@ class Order implements OrderInterface $this->notes = $notes; } - /** - * {@inheritdoc} - */ - public function getSequenceType() - { - return 'order'; - } - /** * {@inheritdoc} */ diff --git a/src/Sylius/Component/Order/Model/OrderInterface.php b/src/Sylius/Component/Order/Model/OrderInterface.php index bdd78e2159..c828c9a6f0 100644 --- a/src/Sylius/Component/Order/Model/OrderInterface.php +++ b/src/Sylius/Component/Order/Model/OrderInterface.php @@ -14,7 +14,6 @@ namespace Sylius\Component\Order\Model; use Doctrine\Common\Collections\Collection; use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\Component\Resource\Model\TimestampableInterface; -use Sylius\Component\Sequence\Model\SequenceSubjectInterface; /** * @author Paweł Jędrzejewski @@ -23,7 +22,6 @@ interface OrderInterface extends AdjustableInterface, CommentAwareInterface, ResourceInterface, - SequenceSubjectInterface, TimestampableInterface { const STATE_NEW = 'new'; diff --git a/src/Sylius/Component/Order/Repository/OrderRepositoryInterface.php b/src/Sylius/Component/Order/Repository/OrderRepositoryInterface.php index 8eb5da09e2..115878fbf5 100644 --- a/src/Sylius/Component/Order/Repository/OrderRepositoryInterface.php +++ b/src/Sylius/Component/Order/Repository/OrderRepositoryInterface.php @@ -13,12 +13,11 @@ namespace Sylius\Component\Order\Repository; use Sylius\Component\Order\Model\OrderInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; -use Sylius\Component\Sequence\Repository\HashSubjectRepositoryInterface; /** * @author Paweł Jędrzejewski */ -interface OrderRepositoryInterface extends RepositoryInterface, HashSubjectRepositoryInterface +interface OrderRepositoryInterface extends RepositoryInterface { /** * @return int diff --git a/src/Sylius/Component/Order/composer.json b/src/Sylius/Component/Order/composer.json index fe30526c84..2e64ee18f6 100644 --- a/src/Sylius/Component/Order/composer.json +++ b/src/Sylius/Component/Order/composer.json @@ -20,9 +20,7 @@ } ], "require": { - "php": "^5.6|^7.0", - - "sylius/sequence": "^1.0" + "php": "^5.6|^7.0" }, "require-dev": { "phpspec/phpspec": "^2.4" diff --git a/src/Sylius/Component/Sequence/.gitignore b/src/Sylius/Component/Sequence/.gitignore deleted file mode 100644 index 46aed33710..0000000000 --- a/src/Sylius/Component/Sequence/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -vendor/ -bin/ - -composer.phar -composer.lock diff --git a/src/Sylius/Component/Sequence/CHANGELOG.md b/src/Sylius/Component/Sequence/CHANGELOG.md deleted file mode 100644 index d97d309fa4..0000000000 --- a/src/Sylius/Component/Sequence/CHANGELOG.md +++ /dev/null @@ -1,6 +0,0 @@ -CHANGELOG -========= - -### v0.10.0 - -* Initial dev release. diff --git a/src/Sylius/Component/Sequence/LICENSE b/src/Sylius/Component/Sequence/LICENSE deleted file mode 100644 index 592b2c08e2..0000000000 --- a/src/Sylius/Component/Sequence/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/Sequence/Model/Sequence.php b/src/Sylius/Component/Sequence/Model/Sequence.php deleted file mode 100644 index bc2a866cc6..0000000000 --- a/src/Sylius/Component/Sequence/Model/Sequence.php +++ /dev/null @@ -1,70 +0,0 @@ -type = $type; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getType() - { - return $this->type; - } - - /** - * {@inheritdoc} - */ - public function getIndex() - { - return $this->index; - } - - /** - * {@inheritdoc} - */ - public function incrementIndex() - { - ++$this->index; - } -} diff --git a/src/Sylius/Component/Sequence/Model/SequenceInterface.php b/src/Sylius/Component/Sequence/Model/SequenceInterface.php deleted file mode 100644 index 2c9e483acd..0000000000 --- a/src/Sylius/Component/Sequence/Model/SequenceInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - */ -interface SequenceSubjectInterface -{ - /** - * @return string - */ - public function getSequenceType(); - - /** - * @return string|null - */ - public function getNumber(); - - /** - * @param string - */ - public function setNumber($number); -} diff --git a/src/Sylius/Component/Sequence/Number/AbstractGenerator.php b/src/Sylius/Component/Sequence/Number/AbstractGenerator.php deleted file mode 100644 index bad4af8034..0000000000 --- a/src/Sylius/Component/Sequence/Number/AbstractGenerator.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @author Saša Stamenković - * @author Alexandre Bacco - */ -abstract class AbstractGenerator implements GeneratorInterface -{ - /** - * {@inheritdoc} - */ - public function generate(SequenceSubjectInterface $subject, SequenceInterface $sequence) - { - if (null !== $subject->getNumber()) { - return; - } - - $subject->setNumber($this->generateNumber($sequence->getIndex(), $subject)); - - $sequence->incrementIndex(); - } - - /** - * Generate the number - * - * @param int $index - * @param SequenceSubjectInterface $subject - * - * @return string - */ - abstract protected function generateNumber($index, SequenceSubjectInterface $subject); -} diff --git a/src/Sylius/Component/Sequence/Number/GeneratorInterface.php b/src/Sylius/Component/Sequence/Number/GeneratorInterface.php deleted file mode 100644 index 8e9acfac44..0000000000 --- a/src/Sylius/Component/Sequence/Number/GeneratorInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - */ -interface GeneratorInterface -{ - /** - * Generate and apply next available number for given subject. - * - * @param SequenceSubjectInterface $subject - * @param SequenceInterface $sequence - */ - public function generate(SequenceSubjectInterface $subject, SequenceInterface $sequence); -} diff --git a/src/Sylius/Component/Sequence/Number/HashGenerator.php b/src/Sylius/Component/Sequence/Number/HashGenerator.php deleted file mode 100644 index 9a5449e79c..0000000000 --- a/src/Sylius/Component/Sequence/Number/HashGenerator.php +++ /dev/null @@ -1,59 +0,0 @@ - - */ -class HashGenerator extends AbstractGenerator implements GeneratorInterface -{ - /** - * @var HashSubjectRepositoryInterface - */ - protected $subjectRepository; - - public function __construct(HashSubjectRepositoryInterface $subjectRepository) - { - $this->subjectRepository = $subjectRepository; - } - - /** - * {@inheritdoc} - * This generates a 3 by 7 by 7 digit number (much like amazon's order identifier) - * e.g. 105-3958356-3707476 - */ - protected function generateNumber($index, SequenceSubjectInterface $order) - { - do { - $number = $this->generateSegment(3).'-'.$this->generateSegment(7).'-'.$this->generateSegment(7); - } while ($this->subjectRepository->isNumberUsed($number)); - - return $number; - } - - /** - * Generates a randomized segment - * - * @param int $length - * - * @return string Random characters - */ - protected function generateSegment($length) - { - return substr(str_pad(mt_rand(), $length, 0, STR_PAD_LEFT), 0, $length); - } -} diff --git a/src/Sylius/Component/Sequence/Number/SequentialGenerator.php b/src/Sylius/Component/Sequence/Number/SequentialGenerator.php deleted file mode 100644 index b2d2afadcb..0000000000 --- a/src/Sylius/Component/Sequence/Number/SequentialGenerator.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @author Saša Stamenković - * @author Alexandre Bacco - */ -class SequentialGenerator extends AbstractGenerator implements GeneratorInterface -{ - /** - * Order number max length. - * - * @var int - */ - protected $numberLength; - - /** - * Start number - * - * @var int - */ - protected $startNumber; - - /** - * Constructor. - * - * @param int $numberLength - * @param int $startNumber - */ - public function __construct($numberLength = 9, $startNumber = 1) - { - $this->numberLength = $numberLength; - $this->startNumber = $startNumber; - } - - /** - * {@inheritdoc} - */ - protected function generateNumber($index, SequenceSubjectInterface $subject) - { - $number = $this->startNumber + $index; - - return str_pad($number, $this->numberLength, 0, STR_PAD_LEFT); - } -} diff --git a/src/Sylius/Component/Sequence/README.md b/src/Sylius/Component/Sequence/README.md deleted file mode 100644 index 38549a9adc..0000000000 --- a/src/Sylius/Component/Sequence/README.md +++ /dev/null @@ -1,47 +0,0 @@ -Sequence Component [![Build status...](https://secure.travis-ci.org/Sylius/Sequence.png?branch=master)](http://travis-ci.org/Sylius/Sequence) -=================== - -Sequences engine for PHP objects. - -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/Sequence/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://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/Sequence/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/Sequence/contributors). diff --git a/src/Sylius/Component/Sequence/Registry/GeneratorRegistry.php b/src/Sylius/Component/Sequence/Registry/GeneratorRegistry.php deleted file mode 100644 index 46248b06b9..0000000000 --- a/src/Sylius/Component/Sequence/Registry/GeneratorRegistry.php +++ /dev/null @@ -1,44 +0,0 @@ - - */ -class GeneratorRegistry extends ServiceRegistry -{ - /** - * Return the generator used for the given entity - * - * @param object $entity - * - * @return GeneratorInterface - * - * @throws NonExistingServiceException - */ - public function get($entity) - { - foreach ($this->services as $interface => $generator) { - if ($entity instanceof $interface) { - return $generator; - } - } - - throw new NonExistingServiceException(get_class($entity)); - } -} diff --git a/src/Sylius/Component/Sequence/Registry/NonExistingGeneratorException.php b/src/Sylius/Component/Sequence/Registry/NonExistingGeneratorException.php deleted file mode 100644 index db29f078e3..0000000000 --- a/src/Sylius/Component/Sequence/Registry/NonExistingGeneratorException.php +++ /dev/null @@ -1,32 +0,0 @@ - - */ -class NonExistingGeneratorException extends \InvalidArgumentException -{ - public function __construct($entity, NonExistingServiceException $e) - { - parent::__construct( - sprintf( - 'Generator for entity "%s" does not exist. Please consider adding it to your configuration like this: sylius_sequence.generators: %%sylius.model.class%%: sylius.sequence.sequential_number_generator', - get_class($entity) - ), - $e->getCode(), - $e - ); - } -} diff --git a/src/Sylius/Component/Sequence/Repository/HashSubjectRepositoryInterface.php b/src/Sylius/Component/Sequence/Repository/HashSubjectRepositoryInterface.php deleted file mode 100644 index 186950e7f2..0000000000 --- a/src/Sylius/Component/Sequence/Repository/HashSubjectRepositoryInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - */ -interface HashSubjectRepositoryInterface -{ - /** - * Is the given number used? - * - * @param $number string - * - * @return bool - */ - public function isNumberUsed($number); -} diff --git a/src/Sylius/Component/Sequence/SyliusSequenceEvents.php b/src/Sylius/Component/Sequence/SyliusSequenceEvents.php deleted file mode 100644 index 5e5eb15020..0000000000 --- a/src/Sylius/Component/Sequence/SyliusSequenceEvents.php +++ /dev/null @@ -1,18 +0,0 @@ - - */ -class SequentialGeneratorSpec extends ObjectBehavior -{ - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Component\Sequence\Number\SequentialGenerator'); - } - - function it_generates_000001_number_for_first_subject( - SequenceSubjectInterface $subject, - SequenceInterface $sequence - ) { - $subject->getNumber()->willReturn(null); - $subject->getSequenceType()->willReturn('order'); - - $sequence->getIndex()->willReturn(0); - $sequence->incrementIndex()->shouldBeCalled(); - - $subject->setNumber('000000001')->shouldBeCalled(); - - $this->generate($subject, $sequence); - } - - function it_generates_a_correct_number_for_following_subjects( - SequenceSubjectInterface $subject, - SequenceInterface $sequence - ) { - $subject->getNumber()->willReturn(null); - $subject->getSequenceType()->willReturn('order'); - - $sequence->getIndex()->willReturn(222); - $sequence->incrementIndex()->shouldBeCalled(); - - $subject->setNumber('000000223')->shouldBeCalled(); - - $this->generate($subject, $sequence); - } - - function it_starts_at_start_number_if_specified(SequenceSubjectInterface $subject, SequenceInterface $sequence) - { - $this->beConstructedWith(6, 123); - - $subject->getNumber()->willReturn(null); - $subject->getSequenceType()->willReturn('order'); - - $sequence->getIndex()->willReturn(0); - $sequence->incrementIndex()->shouldBeCalled(); - - $subject->setNumber('000123')->shouldBeCalled(); - - $this->generate($subject, $sequence); - } - - function it_leaves_existing_numbers_alone(SequenceSubjectInterface $subject, SequenceInterface $sequence) - { - $subject->getNumber()->willReturn('123'); - $subject->setNumber(Argument::any())->shouldNotBeCalled(); - - $sequence->incrementIndex()->shouldNotBeCalled(); - - $this->generate($subject, $sequence); - } -}