我已经实现了一个基于Symfony 3.1的论坛软件包Discutea/DForumBundle,并且希望增强功能并为其添加功能。我到目前为止尝试过How to Override any Part of a Bundle;覆盖视图和语言包是可能的,但我也希望能够添加新的实体并添加新的控制器。Symfony 3.1:如何扩展symfony包的实体?
在FOSUserBundle
的情况下,这是可能的,因为我们可以扩展用户实体并将我们的自定义首选项添加到其中,以便进行调整。什么是实现这种捆绑的最佳方式?
任何提示或帮助,将不胜感激。
====== ADDED详情======
我认为延长实体应该够我,因为我只想增加像观看次数的增加,所有一些新的领域。所以以下是我的新扩展实体:
<?php
namespace AppBundle\Entity;
use Discutea\DForumBundle\Entity\Model\BasePost;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Entity(repositoryClass="AppBundle\Repository\ForumPostRepository")
* @ORM\Table(name="df_post")
*/
class ForumPost extends BasePost
{
/**
* @ORM\Column(type="integer")
* @ORM\Column(name="views_count", type="integer", nullable=true)
*/
protected $viewCounts = 0;
/**
* Set viewCounts
*
* @param integer $viewCounts
*
* @return ForumPost
*/
public function setViewCounts($viewCounts)
{
$this->viewCounts = $viewCounts;
return $this;
}
/**
* Get viewCounts
*
* @return integer
*/
public function getViewCounts()
{
return $this->viewCounts;
}
}
在此之后,我尝试使用控制台进行模式更新;但我得到了以下错误消息:
[主义\ DBAL \架构\ SchemaException该名称为 “my_database.df_post”表已经存在。
如何解决这个问题并更新我现有的模式?在此之后,我打算扩展其他实体。
关于什么我试过到目前为止,我还添加细节。有什么建议么? – Ren