partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

ProjectFixtureLoader.php (1399B)


      1 <?php
      2 
      3 namespace PartKeepr\ProjectBundle\DataFixtures;
      4 
      5 use Doctrine\Common\DataFixtures\AbstractFixture;
      6 use Doctrine\Common\Persistence\ObjectManager;
      7 use PartKeepr\ProjectBundle\Entity\Project;
      8 use PartKeepr\ProjectBundle\Entity\ProjectPart;
      9 
     10 class ProjectFixtureLoader extends AbstractFixture
     11 {
     12     public function load(ObjectManager $manager)
     13     {
     14         $projectPart1 = new ProjectPart();
     15         $projectPart1->setPart($this->getReference('part.1'));
     16         $projectPart1->setQuantity(1);
     17         $projectPart1->setOverageType(ProjectPart::OVERAGE_TYPE_ABSOLUTE);
     18         $projectPart1->setOverage(0);
     19 
     20         $projectPart2 = new ProjectPart();
     21         $projectPart2->setPart($this->getReference('part.2'));
     22         $projectPart2->setQuantity(1);
     23         $projectPart2->setOverageType(ProjectPart::OVERAGE_TYPE_ABSOLUTE);
     24         $projectPart2->setOverage(0);
     25 
     26         $project = new Project();
     27         $project->setName('FOOBAR');
     28         $project->setDescription('none');
     29         $project->addPart($projectPart1);
     30         $project->addPart($projectPart2);
     31 
     32         $manager->persist($project);
     33         $manager->persist($projectPart1);
     34         $manager->persist($projectPart2);
     35         $manager->flush();
     36 
     37         $this->addReference('project', $project);
     38         $this->addReference('projectpart.1', $projectPart1);
     39         $this->addReference('projectpart.2', $projectPart2);
     40     }
     41 }