我已经从CoreBundle(v1.0.0-alpha)扩展了产品模型,我想根据这个新模型更改灯具的行为。请记住CoreBundle \ Fixture \ Factory \ ProductExampleFactory是最终的,我正在寻找一种扩展灯具的方法,所以我不必重写整个班级和整个"默认"套件。
的appbundle \实体\产品
<?php
namespace AppBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\Product as BaseProduct;
/**
* Product
*
* @author leogout
*
* @ORM\Table(name="sylius_product")
* @ORM\Entity
*/
class Product extends BaseProduct
{
/**
* @var ArrayCollection
*
* @ORM\OneToMany(targetEntity="Package", mappedBy="component")
*/
protected $packages;
/**
* @var boolean
*
* @ORM\Column(type="boolean")
*/
protected $exposed;
/**
* @var ArrayCollection
*
* @ORM\OneToMany(targetEntity="Customization", mappedBy="product")
* @ORM\JoinColumn(name="customization_id", referencedColumnName="id")
*/
protected $customizations;
/**
* Product constructor.
*/
public function __construct()
{
parent::__construct();
$this->packages = new ArrayCollection();
$this->customizations = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set exposed
*
* @param boolean $exposed
* @return Product
*/
public function setExposed($exposed)
{
$this->exposed = $exposed;
return $this;
}
/**
* Get exposed
*
* @return boolean
*/
public function getExposed()
{
return $this->exposed;
}
/**
* Add packages
*
* @param Package $packages
* @return Product
*/
public function addPackage(Package $packages)
{
$this->packages[] = $packages;
return $this;
}
/**
* Remove packages
*
* @param Package $packages
*/
public function removePackage(Package $packages)
{
$this->packages->removeElement($packages);
}
/**
* Get packages
*
* @return ArrayCollection
*/
public function getPackages()
{
return $this->packages;
}
/**
* Add customizations
*
* @param Customization $customizations
* @return Product
*/
public function addCustomization(Customization $customizations)
{
$this->customizations[] = $customizations;
return $this;
}
/**
* Remove customizations
*
* @param Customization $customizations
*/
public function removeCustomization(Customization $customizations)
{
$this->customizations->removeElement($customizations);
}
/**
* Get customizations
*
* @return ArrayCollection
*/
public function getCustomizations()
{
return $this->customizations;
}
}
提前致谢!
编辑:
经过一番挖掘后,我发现我需要使用新的ProductFixture
,新的ProductExampleFactory
和新的MyCustomProductFixture
来编写一个全新的夹具,并使用自己的配置文件进行编码。不理想......你有更好的解决方案吗?