When I use:
php app/console doctrine:fixtures:load --fixtures=/var/www/Symfony/src/BISSAP/ForumBundle/DataFixtures/ORM**
I get the following error:
PHP Catchable fatal error: Argument 1 passed to BISSAP\ForumBundle\Entity\Forum::setCategory() must be an instance of BISSAP\ForumBundle\Entity\Category, null given, called in /var/www/Symfony/src/BISSAP/ForumBundle/DataFixtures/ORM/LoadForum.php on line 40 and defined in /var/www/Symfony/src/BISSAP/ForumBundle/Entity/Forum.php on line 184
My Fixture - LoadForum.php:
<?php
namespace BISSAP\ForumBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use BISSAP\ForumBundle\Entity\Forum;
use BISSAP\ForumBundle\Entity\Category;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class LoadForum extends Controller implements FixtureInterface
{
public function load(ObjectManager $manager)
{
$data=array(array('NAME','DESCRTIPTION','60',$manager->getRepository('BISSAPForumBundle:Category')->find('1')),
array('NAME2','DESCRTIPTION2','60',$manager->getRepository('BISSAPForumBundle:Category')->find('2')));
foreach ($data as $for) {
$forum = new Forum();
$forum->setName($for[0]);
$forum->setDescription($for[1]);
$forum->setOrdre($for[2]);
$forum->setCategory($for[3]);
$manager->persist($forum);
}
$manager->flush();
}
}