Skip to content

Commit

Permalink
Merge pull request Sylius#2243 from inspiran/master
Browse files Browse the repository at this point in the history
[Order]WIP order identities
  • Loading branch information
Paweł Jędrzejewski committed Dec 26, 2014
2 parents c7d6ba8 + 85f1140 commit 42aa693
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
7 changes: 7 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ private function addClassesSection(ArrayNodeDefinition $node)
->scalarNode('form')->defaultValue('Sylius\Bundle\OrderBundle\Form\Type\OrderItemType')->end()
->end()
->end()
->arrayNode('order_identity')
->addDefaultsIfNotSet()
->children()
->scalarNode('model')->defaultValue('Sylius\Component\Order\Model\Identity')->end()
->end()
->end()

->arrayNode('adjustment')
->addDefaultsIfNotSet()
->children()
Expand Down
34 changes: 34 additions & 0 deletions Resources/config/doctrine/model/Identity.orm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>

<!--
This file is part of the Sylius package.
(c) Paweł Jędrzejewski
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
-->

<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
>

<mapped-superclass name="Sylius\Component\Order\Model\Identity" table="sylius_order_identity">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>

<field name="name" column="name" type="string" />
<field name="value" column="value" type="string" nullable="true" />

<many-to-one field="order" target-entity="Sylius\Component\Order\Model\OrderInterface" inversed-by="identities">
<join-column name="order_id" referenced-column-name="id" nullable="false" />
</many-to-one>
</mapped-superclass>

</doctrine-mapping>
6 changes: 6 additions & 0 deletions Resources/config/doctrine/model/Order.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
</cascade>
</one-to-many>

<one-to-many field="identities" target-entity="Sylius\Component\Order\Model\IdentityInterface" mapped-by="order" orphan-removal="true">
<cascade>
<cascade-persist/>
</cascade>
</one-to-many>

<field name="itemsTotal" column="items_total" type="integer" />
<field name="adjustmentsTotal" column="adjustments_total" type="integer" />
<field name="total" column="total" type="integer" />
Expand Down
2 changes: 2 additions & 0 deletions SyliusOrderBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ protected function getModelInterfaces()
'Sylius\Component\Order\Model\CommentInterface' => 'sylius.model.comment.class',
'Sylius\Component\Order\Model\OrderInterface' => 'sylius.model.order.class',
'Sylius\Component\Order\Model\OrderItemInterface' => 'sylius.model.order_item.class',
'Sylius\Component\Order\Model\IdentityInterface' => 'sylius.model.order_identity.class',

);
}

Expand Down

0 comments on commit 42aa693

Please sign in to comment.