[Variation] Remove documentation

This commit is contained in:
Kamil Kokot 2016-09-12 15:57:33 +02:00
parent e866f08039
commit c97c316efb
No known key found for this signature in database
GPG key ID: 7BD76F7054D93C89
15 changed files with 2 additions and 640 deletions

View file

@ -1,56 +0,0 @@
Configuration reference
=======================
.. code-block:: yaml
sylius_variation:
driver: ~ # The driver used for persistence layer. Currently only `doctrine/orm` is supported.
resources:
# `variation_name` can be any name, for example `product`, `ad`, or `blog_post`
variation_name:
variable: ~ # Required: The variable model class implementing `VariableInterface`
# of which variants can be created from
variant:
classes:
model: ~ # Required: The variant model class implementing `VariantInterface`
interface: ~
controller: Sylius\Bundle\ResourceBundle\Controller\ResourceController
repository: ~ # Required: The repository class for the variant
factory: Sylius\Component\Resource\Factory\Factory
form:
default: Sylius\Bundle\VariationBundle\Form\Type\VariantType
validation_groups:
default: [ sylius ]
option:
classes:
model: ~ # Required: The option model class implementing `OptionInterface`
interface: ~
repository: ~ # Required: The repository class for the option
controller: Sylius\Bundle\ResourceBundle\Controller\ResourceController
factory: Sylius\Component\Resource\Factory\Factory
form:
default: Sylius\Bundle\VariationBundle\Form\Type\OptionType
choice:
validation_groups:
default: [ sylius ]
translation:
classes:
model: Sylius\Component\Variation\Model\OptionTranslation
interface: Sylius\Component\Variation\Model\OptionTranslationInterface
controller: Sylius\Bundle\ResourceBundle\Controller\ResourceController
repository: ~ # Required: The repository class for the option
factory: Sylius\Component\Resource\Factory\Factory
form:
default: Sylius\Bundle\VariationBundle\Form\Type\OptionTranslationType
validation_groups:
default: [ sylius ]
fields:
default: [ presentation ]
option_value:
model: ~ # Required: The option value model class implementing `OptionValueInterface`
interface: ~
controller: Sylius\Bundle\ResourceBundle\Controller\ResourceController
repository: ~ # Required: The repository class for the option value
factory: Sylius\Component\Resource\Factory\Factory
form:
default: Sylius\Bundle\VariationBundle\Form\Type\OptionValueType

View file

@ -1,15 +0,0 @@
SyliusVariationBundle
=====================
This bundle allows you to manage and generate variations of any compatible object with a very flexible architecture.
Sylius uses this bundle internally for its product catalog to manage variations of the same product based on its options
and their values, but can be used with almost any object.
.. toctree::
:maxdepth: 1
:numbered:
installation
configuration

View file

@ -1,86 +0,0 @@
Installation
============
We assume you're familiar with `Composer <http://packagist.org>`_, a dependency manager for PHP.
Use the following command to add the bundle to your `composer.json` and download the package.
If you have `Composer installed globally <http://getcomposer.org/doc/00-intro.md#globally>`_.
.. code-block:: bash
$ composer require sylius/variation-bundle
Otherwise you have to download .phar file.
.. code-block:: bash
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar require sylius/variation-bundle
Adding required bundles to the kernel
-------------------------------------
You need to enable the bundle inside the kernel.
If you're not using any other Sylius bundles, you will also need to add `SyliusResourceBundle` and its dependencies to kernel.
Don't worry, everything was automatically installed via Composer.
.. code-block:: php
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
new winzou\Bundle\StateMachineBundle\winzouStateMachineBundle(),
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle($this),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
new Sylius\Bundle\VariationBundle\SyliusVariationBundle(),
new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
// Other bundles...
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
);
}
.. note::
Please register the bundle before *DoctrineBundle*. This is important as we use listeners which have to be processed first.
Container configuration
-----------------------
Put this configuration inside your ``app/config/config.yml``.
.. code-block:: yaml
sylius_variation:
driver: doctrine/orm # Configure the doctrine orm driver used in the documentation.
And configure doctrine extensions which are used by the bundle.
.. code-block:: yaml
stof_doctrine_extensions:
orm:
default:
timestampable: true
Updating database schema
------------------------
Run the following command.
.. code-block:: bash
$ php app/console doctrine:schema:update --force
.. warning::
This should be done only in **dev** environment! We recommend using Doctrine migrations, to safely update your schema.
Congratulations! The bundle is now installed and ready to use.

View file

@ -21,6 +21,5 @@ Symfony Bundles
SyliusTaxationBundle/index
SyliusTaxonomyBundle/index
SyliusThemeBundle/index
SyliusVariationBundle/index
.. include:: /bundles/map.rst.inc

View file

@ -15,4 +15,3 @@
* :doc:`/bundles/SyliusTaxationBundle/index`
* :doc:`/bundles/SyliusTaxonomyBundle/index`
* :doc:`/bundles/SyliusThemeBundle/index`
* :doc:`/bundles/SyliusVariationBundle/index`

View file

@ -125,8 +125,3 @@ Product options management
$product->setOptions($options);
$product->hasOptions(); // Returns true.
$product->getOptions(); // Returns an array containing all inserted options.
.. note::
Doesn't matter if you use **Option** objects from this component,
the :doc:`/components/Variation/index` or your custom.
Every model implementing the :ref:`component_variation_model_option-interface` is supported.

View file

@ -54,12 +54,4 @@ to bind an attribute and a value to a specific product.
VariantInterface
~~~~~~~~~~~~~~~~
This interface should be implemented by models binding
a product with a specific combination of attributes.
.. note::
This interface extends the :ref:`component_variation_model_variant-interface`.
For more information go to `Sylius API VariantInterface`_.
.. _Sylius API VariantInterface: http://api.sylius.org/Sylius/Component/Product/Model/VariantInterface.html
This interface should be implemented by models binding a product with a specific combination of attributes.

View file

@ -100,8 +100,7 @@ and provides an additional property:
+-------------+---------------------------------------------------------+
.. note::
This model extends the :ref:`component_variation_model_variant`
and implements the :ref:`component_product_model_variant-interface`.
This model implements the :ref:`component_product_model_variant-interface`.
For more detailed information go to `Sylius API Variant`_.

View file

@ -1,222 +0,0 @@
Basic Usage
===========
VariableInterface
-----------------
Let's see how an exemplary class implementing the **VariableInterface** should look like.
.. code-block:: php
<?php
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Sylius\Component\Variation\Model\OptionInterface;
use Sylius\Component\Variation\Model\VariableInterface;
use Sylius\Component\Variation\Model\VariantInterface;
class Clothing implements VariableInterface
{
/**
* @var string
*/
private $name;
/**
* @var Collection
*/
private $variants;
/**
* @var Collection
*/
private $options;
/**
* @param string $name
*/
public function __construct($name)
{
$this->name = $name;
$this->variants = new ArrayCollection();
$this->options = new ArrayCollection();
}
/**
* {@inheritdoc}
*/
public function hasVariants()
{
return !$this->variants->isEmpty();
}
/**
* {@inheritdoc}
*/
public function getVariants()
{
return $this->variants;
}
/**
* {@inheritdoc}
*/
public function setVariants(Collection $variants)
{
$this->variants = $variants;
}
/**
* {@inheritdoc}
*/
public function addVariant(VariantInterface $variant)
{
$this->variants->add($variant);
}
/**
* {@inheritdoc}
*/
public function removeVariant(VariantInterface $variant)
{
$this->variants->removeElement($variant);
}
/**
* {@inheritdoc}
*/
public function hasVariant(VariantInterface $variant)
{
return $this->variants->contains($variant);
}
/**
* {@inheritdoc}
*/
public function hasOptions()
{
return !$this->options->isEmpty();
}
/**
* {@inheritdoc}
*/
public function getOptions()
{
return $this->options;
}
/**
* {@inheritdoc}
*/
public function setOptions(Collection $options)
{
$this->options = $options;
}
/**
* {@inheritdoc}
*/
public function addOption(OptionInterface $option)
{
$this->options->add($option);
}
/**
* {@inheritdoc}
*/
public function removeOption(OptionInterface $option)
{
$this->options->removeElement($option);
}
/**
* {@inheritdoc}
*/
public function hasOption(OptionInterface $option)
{
return $this->options->contains($option);
}
}
.. _component_variation_generator_variant-generator:
VariantGenerator
----------------
A **VariantGenerator** is used to create all possible combinations of an object's options and to create ``Variant`` models from them.
**Example:**
If an object such as a T-shirt has 2 options - *Color* and *Size* - with 3 possible values per option,
then the generator will create 9 variants and assign them to the object.
The generator will ignore invalid variants or variants that already exist.
**T-Shirt Options**
+------------+----------+
| **Colors** | **Size** |
+------------+----------+
| Black | Small |
+------------+----------+
| White | Medium |
+------------+----------+
| Red | Large |
+------------+----------+
**Possible T-Shirt Variants**
These variants should be generated by the ``VariantGenerator`` from the options above:
1. Black, Small
2. Black, Medium
3. Black, Large
4. White, Small
5. White, Medium
6. White, Large
7. Red, Small
8. Red, Medium
9. Red, Large
.. code-block:: php
<?php
use Sylius\Component\Variation\Generator\VariantGenerator;
use Sylius\Component\Variation\Model\VariableInterface;
use Sylius\Component\Variation\SetBuilder\CartesianSetBuilder;
use Sylius\Component\Resource\Repository\InMemoryRepository;
$variantRepository = new InMemoryRepository();
$setBuilder = new CartesianSetBuilder();
$subject = new Clothing('T-Shirt');
$colors = new Option();
$colors->setValues(new ArrayCollection(array('White', 'Black', 'Red')));
$colors->setName('Color');
$sizes = new Option();
$sizes->setValues(new ArrayCollection(array('Small', 'Medium', 'Large')));
$sizes->setName('Size');
$variable->addOption($colors);
$variable->addOption($sizes);
$generator = new VariantGenerator($variantRepository, $setBuilder);
// Generate all possible variants if they don't exist yet.
$generator->generate($variable)
.. note::
The variant generator implements the :ref:`component_variation_generator_variant-generator-interface`.
.. note::
The variant generator's set builder should implement the :ref:`component_variation_set-builder_set-builder-interface`.

View file

@ -1,12 +0,0 @@
Variation
=========
Library for managing object variants and options. This functionality can be attached to any object to create different configurations.
.. toctree::
:maxdepth: 2
installation
basic_usage
models
interfaces

View file

@ -1,11 +0,0 @@
Installation
============
You can install the component in 2 different ways:
* :doc:`Install it via Composer </components/general/using_components>` (``sylius/variation`` on `Packagist`_);
* Use the official Git repository (https://github.com/Sylius/Variation).
.. include:: /components/require_autoload.rst.inc
.. _Packagist: https://packagist.org/packages/sylius/variation

View file

@ -1,106 +0,0 @@
Interfaces
==========
Model Interfaces
----------------
.. _component_variation_model_variable-interface:
VariableInterface
~~~~~~~~~~~~~~~~~
In order for the object class to manage variants and options it has to implement the ``VariableInterface``.
.. note::
You will find more information about this interface in `Sylius API VariableInterface`_.
.. _Sylius API VariableInterface: http://api.sylius.org/Sylius/Component/Variation/Model/VariableInterface.html
.. _component_variation_model_variant-interface:
VariantInterface
~~~~~~~~~~~~~~~~
When an object class implements the ``VariantInterface`` it has a possibility to manage options.
.. note::
This interface extends the :ref:`component_resource_model_timestampable-interface`.
You will find more information about this interface in `Sylius API VariantInterface`_.
.. _Sylius API VariantInterface: http://api.sylius.org/Sylius/Component/Variation/Model/VariantInterface.htm
.. _component_variation_model_option-interface:
OptionInterface
~~~~~~~~~~~~~~~
In order for an object class to represent the option type it has to implement the ``OptionInterface``.
.. note::
This interface extends :ref:`component_resource_model_code-aware-interface`, :ref:`component_resource_model_timestampable-interface`
and the :ref:`component_variation_model_option-translation-interface`.
You will find more information about this interface in `Sylius API OptionInterface`_.
.. _Sylius API OptionInterface: http://api.sylius.org/Sylius/Component/Variation/Model/OptionInterface.html
.. _component_variation_model_option-translation-interface:
OptionTranslationInterface
~~~~~~~~~~~~~~~~~~~~~~~~~~
In order to store the translation of an **Option** an object class needs to imlement this interface.
.. note::
You will find more information about this interface in `Sylius API OptionTranslationInterface`_.
.. _Sylius API OptionTranslationInterface: http://api.sylius.org/Sylius/Component/Variation/Model/OptionTranslationInterface.html
.. _component_variation_model_option-value-interface:
OptionValueInterface
~~~~~~~~~~~~~~~~~~~~
If you need to store a value of an **Option** you will have to create an object class that implements this interface.
.. note::
This interface extends :ref:`component_resource_model_code-aware-interface`.
You will find more information about that interface in `Sylius API OptionValueInterface`_.
.. _Sylius API OptionValueInterface: http://api.sylius.org/Sylius/Component/Variation/Model/OptionValueInterface.html
Services Interfaces
-------------------
.. _component_variation_set-builder_set-builder-interface:
SetBuilderInterface
~~~~~~~~~~~~~~~~~~~
When you want a service to be able to Build a product set from one or more given sets it should implement the ``SetBuilderInterface``.
.. note::
You will find more information about that interface in `Sylius API SetBuilderInterface`_.
.. _Sylius API SetBuilderInterface: http://api.sylius.org/Sylius/Component/Variation/SetBuilder/SetBuilderInterface.html
.. _component_variation_generator_variant-generator-interface:
VariantGeneratorInterface
~~~~~~~~~~~~~~~~~~~~~~~~~
This interface is used to create all possible (non-existing) variations of a given object based on its options.
.. note::
You will find more information about that interface in `Sylius API VariantGeneratorInterface`_.
.. _Sylius API VariantGeneratorInterface: http://api.sylius.org/Sylius/Component/Variation/SetBuilder/VariantGeneratorInterface.html

View file

@ -1,112 +0,0 @@
Models
======
.. _component_variation_model_variant:
Variant
-------
Every variant is represented by **Variant** instance and has the following properties:
+--------------+---------------------------------------------+
| Property | Description |
+==============+=============================================+
| id | Unique id of the variant |
+--------------+---------------------------------------------+
| presentation | Name displayed to user |
+--------------+---------------------------------------------+
| object | Related product |
+--------------+---------------------------------------------+
| options | Option values |
+--------------+---------------------------------------------+
| createdAt | Date of creation |
+--------------+---------------------------------------------+
| updatedAt | Date of the last update |
+--------------+---------------------------------------------+
.. note::
This model implements the :ref:`component_variation_model_variant-interface`.
You will find more information about this interface in `Sylius API Variant`_.
.. _Sylius API Variant: http://api.sylius.org/Sylius/Component/Variation/Model/Variant.html
.. _component_variation_model_option:
Option
------
Every variant option is represented by **Option** instance and has the following properties:
+--------------+---------------------------------------------+
| Property | Description |
+==============+=============================================+
| id | Unique id of the Option |
+--------------+---------------------------------------------+
| code | Unique code of the Option |
+--------------+---------------------------------------------+
| name | Internal name |
+--------------+---------------------------------------------+
| presentation | Name displayed to user |
+--------------+---------------------------------------------+
| values | Option values |
+--------------+---------------------------------------------+
| createdAt | Date of creation |
+--------------+---------------------------------------------+
| updatedAt | Date of the last update |
+--------------+---------------------------------------------+
.. note::
This model implements the :ref:`component_variation_model_option-interface`.
You will find more information about this interface in `Sylius API Option`_.
.. _Sylius API Option: http://api.sylius.org/Sylius/Component/Variation/Model/Option.html
.. _component_variation_model_option-translation:
OptionTranslation
-----------------
Every variant option has a corresponding translation stored as an **OptionTranslation** instance and has the following properties:
+--------------+---------------------------------------------+
| Property | Description |
+==============+=============================================+
| id | Unique id of the translation |
+--------------+---------------------------------------------+
| presentation | Translated option name |
+--------------+---------------------------------------------+
.. note::
This model implements the :ref:`component_variation_model_option-translation-interface`.
You will find more information about this interface in `Sylius API OptionTranslation`_.
.. _Sylius API OptionTranslation: http://api.sylius.org/Sylius/Component/Variation/Model/OptionTranslation.html
.. _component_variation_model_option_value:
OptionValue
-----------
Every variant option value is represented by **OptionValue** instance and has the following properties:
+--------------+---------------------------------------------+
| Property | Description |
+==============+=============================================+
| id | Unique id of the OptionValue |
+--------------+---------------------------------------------+
| code | Unique code of the OptionValue |
+--------------+---------------------------------------------+
| value | Option internal value |
+--------------+---------------------------------------------+
| option | An instance of Option |
+--------------+---------------------------------------------+
.. note::
This model implements the :ref:`component_variation_model_option-value-interface`.
You will find more information about this interface in `Sylius API OptionValue`_.
.. _Sylius API OptionValue: http://api.sylius.org/Sylius/Component/Variation/Model/OptionValue.html

View file

@ -34,6 +34,5 @@ We recommend checking out :doc:`/components/general/index`, which will get you s
Taxation/index
Taxonomy/index
User/index
Variation/index
.. include:: /components/map.rst.inc

View file

@ -19,4 +19,3 @@
* :doc:`/components/Taxation/index`
* :doc:`/components/Taxonomy/index`
* :doc:`/components/User/index`
* :doc:`/components/Variation/index`