无法从Command获取存储库中的对象

时间:2014-10-22 16:47:11

标签: symfony doctrine entity

我想更新表comments中的某些行。

class TryCommentsCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        //blah-blah-blah
    }

    private function update_comments($step_size, OutputInterface $output)
    {
        $doctrine = $this->getContainer()->get('doctrine');
        $not_moderated_comments = $doctrine->getRepository('***Bundle:Comments')
            ->findBy(array('is_automoderated' => false))
            ->orderBy('c.date', 'DESC')
            ->setMaxResults($step_size)
            ->setFirstResult(0)
            ->getQuery()->getResult();

        for ($not_moderated_comments as $comment) 
        {
            $comment.setIsAutomoderated(true);
            $comment.save();
        }
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {

        self::update_comments(intval($input->getArgument('step')), $output);

    }
}

我写了这个命令并尝试运行它,但得到了错误

Fatal error: Class 'Blogger\BlogBundle\Repository\BlogRepository' not found in C:\Users\.. ..\vendor\doctrine\orm\lib\Doctrine\ORM\Repository\DefaultRepositoryFactory.php on line 75

如何解决?如何从表中获取实体?

UPD:My *** Bundle:评论

namespace pv\***Bundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Comments
 */
class Comments
{
    /**
     * @var integer
     */
    private $id;

    /**
     * @var \DateTime
     */
    private $date;

    /**
     * @var string
     */
    private $name;

    /**
     * @var string
     */
    private $comment;


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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Set comment
     *
     * @param string $comment
     * @return Comments
     */
    public function setComment($comment)
    {
        $this->comment = $comment;

        return $this;
    }

    /**
     * Get comment
     *
     * @return string 
     */
    public function getComment()
    {
        return $this->comment;
    }

}

0 个答案:

没有答案