我在实体文件夹中创建了一个新实体,我已经有了其他一些使用过的实体。但是,这个新实体未被doctrine检测到:mapping:info或doctrine:schema:validate
看来文件根本没有考虑在内(如果我在symfony中写错误就没有问题)。
我正在考虑VM系统问题,但之后我尝试创建其他新文件(例如新的YML,新的symfony表单)并且它可以工作......
我还清除了缓存:clear和doctrine:cache:all options
这是班级:
<?php
namespace NRtworks\BusinessDimensionBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use JsonSerializable;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Table(name="test")
*/
class test implements JsonSerializable
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=50)
*/
protected $name;
/**
* @ORM\Column(type="string", length=100)
*/
protected $description;
/**
* Constructor
*/
public function __construct($id = NULL)
{
$this->id = $id;
$this->name = "Chart Of Accounts";
$this->description = "Default chart of accounts";
}
//this method returns an array with default values
public function getDefaultObject()
{
$result = Array();
$result['id'] = $this->id;
$result['name'] = $this->name;
$result['description'] = $this->code;
return $result;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
}
/**
* Set name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* Get name
*/
public function getName()
{
return $this->name;
}
/**
* Set code
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* Get description
*/
public function getDescription()
{
return $this->description;
}
public function jsonSerialize()
{
return array(
'id' => $this->id,
'name' => $this->name,
'description' => $this->description
);
}
}
?>
这可能来自哪里?
答案 0 :(得分:3)
您需要为您的班级定义@ORM\Entity
注释:
/**
* @ORM\Entity
* @ORM\Table(name="test")
*/
class test implements JsonSerializable
{