Skip to content

Commit

Permalink
Merge pull request Sylius#341 from stloyd/bugfix/doctrine_mapping
Browse files Browse the repository at this point in the history
Fix for doctrine mappings issues in ShippingBundle.
  • Loading branch information
Paweł Jędrzejewski committed Sep 25, 2013
2 parents d251ad7 + c8b037c commit fe79729
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 10 deletions.
41 changes: 39 additions & 2 deletions src/Sylius/Bundle/ShippingBundle/Model/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,37 @@

namespace Sylius\Bundle\ShippingBundle\Model;

use Sylius\Bundle\ShippingBundle\Model\ShippingMethodInterface;

/**
* Shipping method rule model.
*
* @author Saša Stamenković <[email protected]>
*/
class Rule implements RuleInterface
{
/**
* Shipping rule identifier.
*
* @var mixed
*/
protected $id;

/**
* Rule type.
*
* @var string
*/
protected $type;

/**
* All extra configuration.
*
* @var array
*/
protected $configuration;

/**
* @var ShippingMethodInterface
*/
protected $method;

public function __construct()
Expand All @@ -35,31 +54,49 @@ public function getId()
return $this->id;
}

/**
* {@inheritdoc}
*/
public function getType()
{
return $this->type;
}

/**
* {@inheritdoc}
*/
public function setType($type)
{
$this->type = $type;
}

/**
* {@inheritdoc}
*/
public function getConfiguration()
{
return $this->configuration;
}

/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration)
{
$this->configuration = $configuration;
}

/**
* {@inheritdoc}
*/
public function getMethod()
{
return $this->method;
}

/**
* {@inheritdoc}
*/
public function setMethod(ShippingMethodInterface $method = null)
{
$this->method = $method;
Expand Down
25 changes: 23 additions & 2 deletions src/Sylius/Bundle/ShippingBundle/Model/RuleInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Sylius\Bundle\ShippingBundle\Model;

use Sylius\Bundle\ShippingBundle\Model\ShippingMethodInterface;

/**
* Shipping method rule model interface.
*
Expand All @@ -24,10 +22,33 @@ interface RuleInterface
const TYPE_ITEM_COUNT = 'item_count';
const TYPE_WEIGHT = 'weight';

/**
* @return string
*/
public function getType();

/**
* @param string $type
*/
public function setType($type);

/**
* @return array
*/
public function getConfiguration();

/**
* @param array $configuration
*/
public function setConfiguration(array $configuration);

/**
* @return null|ShippingMethodInterface
*/
public function getMethod();

/**
* @param null|ShippingMethodInterface $method
*/
public function setMethod(ShippingMethodInterface $method = null);
}
2 changes: 1 addition & 1 deletion src/Sylius/Bundle/ShippingBundle/Model/ShippingMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ShippingMethod implements ShippingMethodInterface
/**
* Shipping method rules.
*
* @var ArrayCollection
* @var RuleInterface[]
*/
protected $rules;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Sylius\Bundle\ShippingBundle\Model;

use Doctrine\Common\Collections\Collection;

/**
* Shipping subject.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">

<mapped-superclass name="Sylius\Bundle\ShippingBundle\Model\Rule" table="sylius_shipping_rule">
<id name="id" type="integer">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>

<field name="type" type="string" />
<field name="configuration" type="array" />
<field name="type" column="type" type="string" />
<field name="configuration" column="configuration" type="array" />

<many-to-one field="method" target-entity="Sylius\Bundle\ShippingBundle\Model\ShippingMethodInterface">
<many-to-one field="method" target-entity="Sylius\Bundle\ShippingBundle\Model\ShippingMethodInterface" inversed-by="rules">
<join-column name="method_id" referenced-column-name="id" nullable="false" />
</many-to-one>
</mapped-superclass>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<field name="name" column="name" type="string" />
<field name="configuration" column="configuration" type="array" />

<many-to-one field="category" target-entity="Sylius\Bundle\ShippingBundle\Model\ShippingCategoryInterface" inversed-by="methods">
<many-to-one field="category" target-entity="Sylius\Bundle\ShippingBundle\Model\ShippingCategoryInterface">
<join-column name="category_id" referenced-column-name="id" nullable="true" />
</many-to-one>

Expand Down

0 comments on commit fe79729

Please sign in to comment.