diff -r b36a42d260d8 -r 624e5900f5a4 src/Company/BaseBundle/DataFixtures/ORM/LoadDocumentData.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Company/BaseBundle/DataFixtures/ORM/LoadDocumentData.php Wed Dec 14 23:28:58 2011 +0100 @@ -0,0 +1,56 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace Company\BaseBundle\DataFixures\ORM; + +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Doctrine\Common\DataFixtures\FixtureInterface; +use Company\BaseBundle\Entity\Document; + +class LoadDocumentData implements FixtureInterface, ContainerAwareInterface +{ + private $container; + + public function setContainer(ContainerInterface $container = null) + { + $this->container = $container; + } + + public function load($manager) { + + # create new document + + $doc_def_list = array( + array('title'=>'Title 1', 'description'=>'Description 1', 'tags' => array('tag1', 'tag2', 'tag3', 'tag4')), + array('title'=>'Title 2', 'description'=>'Description 2', 'tags' => array('tag2', 'tag3', 'tag4')), + array('title'=>'Title 3', 'description'=>'Description 3', 'tags' => array('tag3', 'tag4')), + array('title'=>'Title 4', 'description'=>'Description 4', 'tags' => array()), + ); + + foreach ($doc_def_list as $doc_def) { + + $newdoc = new Document(); + $newdoc->setTitle($doc_def['title']); + $newdoc->setDescription($doc_def['description']); + + $manager->persist($newdoc); + + $manager->flush(); + + $this->container->get('wiki_tag.document')->addTags($newdoc->getId(), $doc_def['tags']); + } + + # add tags + + $manager->flush(); + + } + +} \ No newline at end of file