Php 可捕获的致命错误:symfony2

Php 可捕获的致命错误:symfony2,php,symfony,Php,Symfony,我是symfony2的新手,启动了一个简单的Symbog项目,创建了一个帖子和评论的crud,当我创建了一个评论的crud时,一切都很好,但现在我必须坚持、合并和删除我的帖子,我有以下错误: 可捕获致命错误:参数1传递给 Notifiable\Repository\Notifiarepository::adicionar()必须是 代理的实例\uuuu CG\uuuuu\noticeable\Entity\noticeia,的实例 可通知\Entity\Noticia已给定,已调用 C:\Des

我是symfony2的新手,启动了一个简单的Symbog项目,创建了一个帖子和评论的crud,当我创建了一个评论的crud时,一切都很好,但现在我必须坚持、合并和删除我的帖子,我有以下错误:

可捕获致命错误:参数1传递给 Notifiable\Repository\Notifiarepository::adicionar()必须是 代理的实例\uuuu CG\uuuuu\noticeable\Entity\noticeia,的实例 可通知\Entity\Noticia已给定,已调用 C:\Desenvolvimento\wamp\www\myproject\src\noticable\Controller\noticacontroller.php 在第49行并定义

控制器持久化功能:

/**
 * @Route("/cadastrar_noticia", name="_cadastrar_noticia")
 * @Template()
 */
public function cadastrarAction() {
    $noticia = new Noticia();
    $request = $this->getRequest();
    $form = $this->createForm(new NoticiaType(), $noticia);
    $form->handleRequest($request);

    if ($form->isValid()) {
        try {
            $noticia = $form->getData();

            $noticiaRepository = $this->getDoctrine()->getRepository('NoticiaBundle:Noticia');
            $noticiaRepository->adicionar($noticia);

            $this->addFlash('success', 'Noticia cadastrada com sucesso');

            return $this->redirectToRoute('_imagem_raias_index');
        } catch (Exception $ex) {
            echo $ex->getMessage();
        }
    }

    return array("form" => $form->createView());
}
持久存储库

 public function adicionar(Noticia $noticia) {

    $this->_em->persist($noticia);
    $this->_em->flush();
    return true;

}
还有我的模板

<?php

namespace NoticiaBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class NoticiaType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('titulo',null, array('attr' => array('class' => 'form-control'),
                'label_attr' => array('class' => 'control-label col-lg-2')
            ))
            ->add('imagem',null, array('attr' => array('class' => 'form-control'),
                'label_attr' => array('class' => 'control-label col-lg-2')
            ))
            ->add('noticia','textarea', array('attr' => array('class' => 'form-control', 'rows' => 15),
                'label_attr' => array('class' => 'control-label col-lg-2')
            ))
            ->add('tags',null, array('attr' => array('class' => 'form-control'),
                'label_attr' => array('class' => 'control-label col-lg-2')
            ))
            ->add('salvar', 'submit', array('attr' => array('class' => 'btn btn-primary pull-right')));
    }

    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'NoticiaBundle\Entity\Noticia'
        ));
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'noticiabundle_noticia';
    }
}

在您定义了
adicionar
的存储库中,检查您的
use
语句。您需要使其引用实际模型,而不是代理。

在您定义的存储库中,检查您的
使用声明。您需要使其引用实际模型,而不是代理