找不到实体

时间:2013-12-09 19:45:07

标签: php symfony doctrine twig

我在symfony2中只有一堂课遇到麻烦, 每当我尝试在模板中使用实体时,它表示未找到实体。 但是在localhost(dev和prod环境工作)上一切都运行得很好,但是当我在远程网络服务器上部署它时,一切都停止了。

我已经重新启动了httpd并尝试了不同的方法。

Entity UserApplication在Application实体上有一个关联,我试图通过模板文件中的UserApplication从应用程序中获取名称

这是我正在抛出的错误消息,

  

[错误]:渲染期间抛出异常   模板(“未找到实体。”)   第34行的“MyBundle:Application:applications_user.html.twig”   代码:0(文件:mylocation / 20131209193528 / app / cache / prod / classes.php,   行:4485)

Snippet:applications_user.html.twig

{% extends 'MaximCMSBundle:Default:index.html.twig' %}

{% block body %}
    <div class="page">
        <h3 class="page-header">Applications</h3>
        <div class="page-content">
            <ul class="menu menu-clean">
                {% for application in applications %}
                    <li>
                        <a href="{{ path('application_view', {'id' : application.id, 'name' : application.application.name}) }}"><span>{{ application.application.name }}</span></a>
                    </li>
                {% else %}
                    <p>There are no open applications at the moment</p>
                {% endfor %}
            </ul>
        </div>
    </div>
{% endblock %}

实体UserApplication

<?php

namespace MyName\Module\ApplicationBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * UserApplication
 *
 * @ORM\Table(name="user_application")
 * @ORM\Entity
 */
class UserApplication {
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    protected $id;

    /**
     * @var User
     *
     * @ORM\ManyToOne(targetEntity="MyName\MyBundle\Entity\User")
     */
    protected $user;

    /**
     * @var json_array $details
     *
     * @ORM\Column(name="details", type="json_array", nullable=false)
     */
    protected $details;

    /**
     * @var \DateTime $date
     *
     * @ORM\Column(name="date", type="datetime", nullable=true)
     */
    protected $date;

    /**
     * @var integer $denied
     *
     * @ORM\Column(name="denied", type="integer", nullable=false)
     */
    protected $denied = 0;

    /**
     * @var Application
     *
     * @ORM\ManyToOne(targetEntity="Application", inversedBy="userApplications")
     */
    protected $application;

    /**
     * @param Application $application
     */
    public function setApplication($application)
    {
        $this->application = $application;
    }

    /**
     * @return Application
     */
    public function getApplication()
    {
        return $this->application;
    }

    /**
     * @param \DateTime $date
     */
    public function setDate($date)
    {
        $this->date = $date;
    }

    /**
     * @return \DateTime
     */
    public function getDate()
    {
        return $this->date;
    }

    /**
     * @param int $denied
     */
    public function setDenied($denied)
    {
        $this->denied = $denied;
    }

    /**
     * @return int
     */
    public function getDenied()
    {
        return $this->denied;
    }

    /**
     * @param int $id
     */
    public function setId($id)
    {
        $this->id = $id;
    }

    /**
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param \MyName\MyBundle\Entity\User $user
     */
    public function setUser($user)
    {
        $this->user = $user;
    }

    /**
     * @return \MyName\MyBundle\Entity\User
     */
    public function getUser()
    {
        return $this->user;
    }

    /**
     * @param \MyName\MyBundle\Entity\json_array $details
     */
    public function setDetails($details)
    {
        $this->details = $details;
    }

    /**
     * @return \MyName\MyBundle\Entity\json_array
     */
    public function getDetails()
    {
        return $this->details;
    }

    public function getApplicationEntityName()
    {
        return "MyNameModuleApplicationBundle:Application";
    }

    public function __toString()
    {
        return "";
    }

}

实体申请:

<?php

namespace MyName\Module\ApplicationBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
 * MyName\Module\ApplicationBundle\Entity\Application
 *
 * @ORM\Table(name="application")
 * @ORM\Entity
 */
class Application
{
    const FIELD_NAME = "NAME";
    const FIELD_TYPE = "TYPE";

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="IDENTITY")
     *
     * @var integer $id
     */
    protected $id;

    /**
     * @var Rank
     *
     * @ORM\ManyToOne(targetEntity="\MyName\MyBundle\Entity\Rank")
     * @ORM\JoinColumn(name="rank_id", referencedColumnName="id", nullable=false)
     */
    protected $rank;

    /**
     * @var Website
     *
     * @ORM\ManyToOne(targetEntity="\MyName\MyBundle\Entity\Website")
     * @ORM\JoinColumn(name="website_id", referencedColumnName="id", nullable=false)
     */
    protected $website;

    /**
     * @var string $name
     *
     * @ORM\Column(name="application_name", type="string", nullable=false)
     */
    protected $name;

    /**
     * @var string $enabled
     *
     * @ORM\Column(name="application_enabled", type="integer", nullable=false)
     */
    protected $enabled = 0;

    /**
     * @var array $fields
     *
     * @ORM\Column(name="application_fields", type="json_array", nullable=true)
     */
    protected $fields;

    /**
     *
     * @ORM\OneToMany(targetEntity="UserApplication", mappedBy="application")
     */
    protected $userApplications;

    public function __construct()
    {
        $this->date = new \DateTime("now");
        $this->userApplications = new ArrayCollection();
    }

    /**
     * @param string $enabled
     */
    public function setEnabled($enabled)
    {
        $this->enabled = $enabled;
    }

    /**
     * @return string
     */
    public function getEnabled()
    {
        return $this->enabled;
    }

    /**
     * @param string $path
     */
    public function setPath($path)
    {
        $this->path = $path;
    }

    /**
     * @return string
     */
    public function getPath()
    {
        return $this->path;
    }

    /**
     * @param int $id
     */
    public function setId($id)
    {
        $this->id = $id;
    }

    /**
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param \MyName\MyBundle\Entity\Rank $rank
     */
    public function setRank($rank)
    {
        $this->rank = $rank;
    }

    /**
     * @return \MyName\MyBundle\Entity\Rank
     */
    public function getRank()
    {
        return $this->rank;
    }

    /**
     * @param \MyName\MyBundle\Entity\Website $website
     */
    public function setWebsite($website)
    {
        $this->website = $website;
    }

    /**
     * @return \MyName\MyBundle\Entity\Website
     */
    public function getWebsite()
    {
        return $this->website;
    }

    /**
     * @param string $name
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param array $fields
     */
    public function setFields($fields)
    {
        $this->fields = $fields;
    }

    /**
     * @return array
     */
    public function getFields()
    {
        return $this->fields;
    }

    function __toString()
    {
        return $this->name;
    }

    /**
     * @param mixed $userApplications
     */
    public function setUserApplications($userApplications)
    {
        $this->userApplications = $userApplications;
    }

    /**
     * @return mixed
     */
    public function getUserApplications()
    {
        return $this->userApplications;
    }


}

1 个答案:

答案 0 :(得分:1)

在删除那些按预期工作的所有内容之后,我显然已经存在与应用程序冲突的现有记录。这就是为什么它在开发环境而不是在生产环境中工作的原因。

感谢所有支持