我使用 SyliusSandbox 包开发商店。Sylius 使用 xml 文件来存储实体的 ORM 模式。
我已将其 xml 定义复制到我的 Bundle 并在那里使用它。
但对于我自己的实体,我想使用注释。所以,基本上我需要在一个包中混合两种类型的定义。如果我尝试保留一个使用注释的实体,我会收到一个错误,即找不到该实体的 xml 文件:
找不到类“\ShopBundle\Entity\ProductLocalized”的名为“ShopBundle\Resources\config\doctrine/ProductLocalized.orm.xml”的映射文件。
我的实体如下所示:
<?php
namespace Pixeljets\ShopBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Pixeljets\ShopBundle\Entity\ProductLocalized
*
* @ORM\Table(name="product_localized")
* @ORM\Entity
*/
class ProductLocalized
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="Product", inversedBy="localized")
* @ORM\JoinColumn(name="product_id", referencedColumnName="id")
*/
protected $product;
/**
* @var integer $product_id
*
* @ORM\Column(name="product_id", type="integer")
*/
private $product_id;
/**
* @var string $title
*
* @ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* @var string $url
*
* @ORM\Column(name="url", type="string", length=255)
*/
private $url;
/**
* @var string $keywords
*
* @ORM\Column(name="keywords", type="string", length=255, nullable=true)
*/
private $keywords;
/**
* @var string $description
*
* @ORM\Column(name="description", type="string", length=255, nullable=true)
*/
private $description;
/**
* @var string $body
*
* @ORM\Column(name="body", type="text", nullable=true)
*/
private $body;
/**
* @var boolean $published
*
* @ORM\Column(name="published", type="boolean")
*/
private $published;
/**
* @var string $lang
*
* @ORM\Column(name="lang", type="string", length=2)
*/
private $lang;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set product_id
*
* @param integer $productId
* @return ProductLocalized
*/
public function setProductId($productId)
{
$this->product_id = $productId;
return $this;
}
/**
* Get product_id
*
* @return integer
*/
public function getProductId()
{
return $this->product_id;
}
/**
* Set title
*
* @param string $title
* @return ProductLocalized
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set url
*
* @param string $url
* @return ProductLocalized
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* Get url
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set keywords
*
* @param string $keywords
* @return ProductLocalized
*/
public function setKeywords($keywords)
{
$this->keywords = $keywords;
return $this;
}
/**
* Get keywords
*
* @return string
*/
public function getKeywords()
{
return $this->keywords;
}
/**
* Set description
*
* @param string $description
* @return ProductLocalized
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set body
*
* @param string $body
* @return ProductLocalized
*/
public function setBody($body)
{
$this->body = $body;
return $this;
}
/**
* Get body
*
* @return string
*/
public function getBody()
{
return $this->body;
}
/**
* Set published
*
* @param boolean $published
* @return ProductLocalized
*/
public function setPublished($published)
{
$this->published = $published;
return $this;
}
/**
* Get published
*
* @return boolean
*/
public function getPublished()
{
return $this->published;
}
/**
* Set lang
*
* @param string $lang
* @return ProductLocalized
*/
public function setLang($lang)
{
$this->lang = $lang;
return $this;
}
/**
* Get lang
*
* @return string
*/
public function getLang()
{
return $this->lang;
}
/**
* Set product
*
* @param Pixeljets\ShopBundle\Entity\Product $product
* @return ProductLocalized
*/
public function setProduct(\Pixeljets\ShopBundle\Entity\Product $product = null)
{
$this->product = $product;
return $this;
}
/**
* Get product
*
* @return Pixeljets\ShopBundle\Entity\Product
*/
public function getProduct()
{
return $this->product;
}
}
?>
我如何“告诉” symfony 对模式使用注释方法?