SHARE
TWEET

Migrations/Data/ORM/LoadCalendarEventTypeData.php

a guest Jun 27th, 2015 16 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace BP\CalendarBundle\Migrations\Data\ORM;
  4.  
  5. use Doctrine\Common\DataFixtures\AbstractFixture;
  6. use Doctrine\Common\Persistence\ObjectManager;
  7.  
  8. use Oro\Bundle\EntityExtendBundle\Entity\Repository\EnumValueRepository;
  9. use Oro\Bundle\EntityExtendBundle\Tools\ExtendHelper;
  10.  
  11. class LoadCalendarEventTypeData extends AbstractFixture
  12. {
  13.     /** @var array */
  14.     protected $data = [
  15.         'Spotkanie' => true,
  16.         'Rozmowa telefoniczna' => false,
  17.         'Inne' => false,
  18.         'Czas prywatny' => false,
  19.     ];
  20.  
  21.     /**
  22.      * @param ObjectManager $manager
  23.      */
  24.     public function load(ObjectManager $manager)
  25.     {
  26.         $className = ExtendHelper::buildEnumValueClassName('calendar_event_type');
  27.  
  28.         /** @var EnumValueRepository $enumRepo */
  29.         $enumRepo = $manager->getRepository($className);
  30.  
  31.         $priority = 1;
  32.         foreach ($this->data as $name => $isDefault) {
  33.             $enumOption = $enumRepo->createEnumValue($name, $priority++, $isDefault);
  34.             $manager->persist($enumOption);
  35.         }
  36.  
  37.         $manager->flush();
  38.     }
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top