/**
  * Main load function.
  *
  * @param Doctrine\Common\Persistence\ObjectManager $manager
  */
 function load(ObjectManager $manager)
 {
     $affiliates = $this->getModelFixtures();
     // Now iterate thought all fixtures
     foreach ($jobs['Job'] as $reference => $columns) {
         // Create our new Job entity
         $job = new Job();
         // Assign category from the fixtures references
         $category = $this->getReference('Category_' . $columns['Category']);
         $job->setCategory($category);
         // Now assign standart values
         $job->setType(isset($columns['type']) ? $columns['type'] : null);
         $job->setCompany($columns['company']);
         $job->setLogo(isset($columns['logo']) ? $columns['logo'] : null);
         $job->setLocation($columns['location']);
         $job->setUrl(isset($columns['url']) ? $columns['url'] : null);
         $job->setPosition($columns['position']);
         $job->setDescription($columns['description']);
         $job->setHowToApply($columns['how_to_apply']);
         $job->setIsPublic($columns['is_public']);
         $job->setIsActivated($columns['is_activated']);
         $job->setToken($columns['token']);
         $job->setEmail($columns['email']);
         $manager->persist($job);
         $manager->flush();
         // Add a reference to be able to use this object in others loaders
         $this->addReference('Job_' . $reference, $job);
     }
     // Insert additional
     $this->duplicateLastJob($manager, $job);
 }
 /**
  * Main load function.
  *
  * @param Doctrine\Common\Persistence\ObjectManager $manager
  */
 function load(ObjectManager $manager)
 {
     $jobs = $this->getModelFixtures();
     // Now iterate thought all fixtures
     foreach ($jobs['Job'] as $reference => $columns) {
         // Create our new Job entity
         $job = new Job();
         // Assign category from the fixtures references
         $category = $this->getReference('Category_' . $columns['Category']);
         $job->setCategory($category);
         // Now assign standart values
         $job->setType(isset($columns['type']) ? $columns['type'] : null);
         $job->setCompany($columns['company']);
         $job->setLogo(isset($columns['logo']) ? $columns['logo'] : null);
         $job->setLocation($columns['location']);
         $job->setUrl(isset($columns['url']) ? $columns['url'] : null);
         $job->setPosition($columns['position']);
         $job->setDescription($columns['description']);
         $job->setHowToApply($columns['how_to_apply']);
         $job->setIsPublic($columns['is_public']);
         $job->setIsActivated($columns['is_activated']);
         $job->setToken($columns['token']);
         $job->setEmail($columns['email']);
         // Don't persiste the job_add fixture because its the reference job for duplication
         if ('job_add' != $reference) {
             $manager->persist($job);
             $manager->flush();
             // Add a reference to be able to use this object in others loaders
             $this->addReference('Job_' . $reference, $job);
         }
         // Force the date fields for this "expired and old" job offer
         if ('expired_job' == $reference) {
             $job->setExpiresAt(new \DateTime(isset($columns['expires_at']) ? $columns['expires_at'] : null));
             $job->setCreatedAt(new \DateTime(isset($columns['expires_at']) ? $columns['expires_at'] : null));
             $manager->persist($job);
             $manager->flush();
         }
     }
     // Insert additional
     $this->duplicateLastJob($manager, $job);
 }