2013-05-29 2 views
0

Symfony2로 고전적인 Blog 응용 프로그램을 구현 중이며 "app/console doctrine : fixtures : load"오류가 발생합니다. 내 BlogFixtures.php 파일은 다음과 같다 :오류 symfony2 비품을로드 할 때 "객체가 아닌 객체에 대한 호출"오류가 발생했습니다.

<?php 
namespace MGF\Bundles\WebBundle\DataFixtures\ORM; 

use Doctrine\Common\DataFixtures\AbstractFixture; 
use Doctrine\Common\DataFixtures\FixtureInterface; 
use Doctrine\Common\Persistence\ObjectManager; 
use MGF\Bundles\WebBundle\Entity\Blog; 
use MGF\Bundles\CRMBundle\Util\Util; 

class BlogFixtures extends AbstractFixture implements FixtureInterface 
{ 
    public function load(ObjectManager $em) 
    { 
     $blog1 = new Blog(); 

     $title = 'First post'; 
     $blog1->setTitle($title); 

     $slug1 = Util::getSlug($title); 
     $blog1->setSlug($slug1); 

     $blog1->setImage('beach.jpg'); 
     $blog1->setTags('symfony2, php, paradise, symblog'); 
     $blog1->setCreated(new \DateTime('now')); 
     $blog1->setUpdated($blog1->getCreated()); 

     $em->persist($blog1); 

     $author1 = $em->getRepository('MGFBCBundle:User')->findOneByUser('sarah'); 
     $author1->addBlog($blog1); 

     $em->persist($author1); 
     $em->flush(); 
    } 
} 

그리고 오류 : 내가 잘못 어디

app/console doctrine:fixtures:load 
Careful, database will be purged. Do you want to continue Y/N ?Y 
    > purging database 
    > loading MGF\Bundles\WebBundle\DataFixtures\ORM\BlogFixtures 
PHP Fatal error: Call to a member function addBlog() on a non-object in /var/www/METRO/src/MGF/Bundles/WebBundle/DataFixtures/ORM/BlogFixtures.php on line 33 

Fatal error: Call to a member function addBlog() on a non-object in /var/www/METRO/src/MGF/Bundles/WebBundle/DataFixtures/ORM/BlogFixtures.php on line 33 

표시되지 않습니다. 어떤 힌트?

미리 감사드립니다.

+0

'sarah'사용자가 db에 존재하며 모든 컨트롤러에서 검색 할 수 있음은 물론입니다. – gomman

+1

var_dump ($ author1)의 정의는 무엇입니까? –

+0

@ Teo.sk는 조명기 파일에서 var_dump 할 수 있습니까? 콘솔이 결과를 인쇄합니까? (나는 afk이고 45 분 동안 돌아 오지 않을 것이고, 나는 나중에 시도 할 것이다) – gomman

답변