Load data fixtures with the passed EntityManager.

@param ObjectManager $manager
12794
public function load(ObjectManager $manager)
    {
        /**
         * @var ObjectDirector $manufacturerDirector
         */
        $manufacturerDirector = $this->getDirector('manufacturer');

        $manufacturer = $manufacturerDirector
            ->create()
            ->setName('manufacturer')
            ->setSlug('manufacturer')
            ->setDescription('manufacturer description');

        $manufacturerDirector->save($manufacturer);
        $this->addReference('manufacturer', $manufacturer);
    }
435039
public function load(ObjectManager $manager)
    {
        $roles = $manager->getRepository('ClarolineCoreBundle:Role')
            ->findAllPlatformRoles();

        //name, isConfigurable, isDisplayableInDesktop, isDisplayableInWorkspace
        $items = array(
            array('core_resource_logger', true, true, true),
            array('simple_text', true, true, true),
            array('my_workspaces', false, true, false),
            array('my_profile', false, true, false),
        );

        foreach ($items as $item) {
            $widget = new Widget();
            $widget->setName($item[0]);
            $widget->setConfigurable($item[1]);
            $widget->setPlugin(null);
            $widget->setExportable(false);
            $widget->setDisplayableInDesktop($item[2]);
            $widget->setDisplayableInWorkspace($item[3]);

            foreach ($roles as $role) {
                $widget->addRole($role);
            }
            $manager->persist($widget);
        }
    }
815517
public function load(ObjectManager $manager)
    {
        /**
         * @var ObjectDirector $menuNodeDirector
         */
        $menuNodeDirector = $this->getDirector('menu_node');

        $menuNodeHim = $menuNodeDirector
            ->create()
            ->setName('him')
            ->setCode('him')
            ->setUrl('elcodi.dev/him')
            ->setActiveUrls([])
            ->setEnabled(true);

        $menuNodeHer = $menuNodeDirector
            ->create()
            ->setName('her')
            ->setCode('her')
            ->setUrl('elcodi.dev/her')
            ->setActiveUrls(
                [
                    'her_products_list_route',
                    'her_offers_list_route',
                ]
            )
            ->setEnabled(true);

        $menuNodeVogue = $menuNodeDirector
            ->create()
            ->setName('vogue')
            ->setCode('vogue')
            ->setEnabled(true)
            ->setActiveUrls([])
            ->addSubnode($menuNodeHim)
            ->addSubnode($menuNodeHer);

        $menuNodeDirector->save($menuNodeVogue);
        $this->addReference('menu-node-him', $menuNodeHim);
        $this->addReference('menu-node-her', $menuNodeHer);
        $this->addReference('menu-node-vogue', $menuNodeVogue);
    }
591724
public function load(ObjectManager $em) {
    foreach ($this->examples as $list) {
      list($example, $context) = $list;

      $fixture = new NestedSetFixture($example, $context);
      $fixture->load($em);
    }
  }
447494
protected function loadManager($args, $options)
    {
        if (null === $this->getManager()) {
            $manager = new Manager($this->getConfig(), $args, $options);
            $this->setManager($manager);
        }
    }
191807
public function load(ObjectManager $manager)
    {
        $exchange = new Exchange();
        $exchange->setName('The Harvest Cloud');

        $manager->persist($exchange);
        $manager->flush();
    }
1310902
protected function loadFromObjectManager(ClassMetadata $metadata, $data)
    {
        // Locate possible ObjectManager
        if (null === $objectManager = $this->getObjectManager($metadata)) {
            return null;
        }

        // Locate possible ClassMetadata
        $classMetadataFactory = $objectManager->getMetadataFactory();

        if ($classMetadataFactory->isTransient($metadata->getName())) {
            // No ClassMetadata found, proceed with normal deserialization
            return null;
        }

        if (! \is_array($data)) {
            // Single identifier, load
            return $objectManager->find($metadata->getName(), $data);
        }

        // Fallback to default constructor if missing identifier(s)
        $classMetadata = $objectManager->getClassMetadata($metadata->getName());
        $identifierList = [];

        foreach ($classMetadata->getIdentifierFieldNames() as $name) {
            if (! \array_key_exists($name, $data)) {
                continue;
            }

            $identifierList[$name] = $data[$name];
        }

        if (0 === \count($identifierList)) {
            return null;
        }

        // Entity update, load it from database
        return $objectManager->find($metadata->getName(), $identifierList);
    }
464134
public function load(ObjectManager $manager)
    {
        for($i=1; $i <= 4; $i++)
        {

            $post = new Post();
            $post->setName('title'.$i);
            $post->setSlug('title-'.$i);
            $post->setContent('content '.$i);
            $post->setCreatedAt(new \DateTime());

            $manager->persist($post);
            $manager->flush();

        }
    }
550174
public function setManager(Closure $manager)
    {
        if (!is_callable($manager)) {
            throw new Exception('Manager must be callable.');
        }

        $this->manager = $manager;

        return $this;
    }
1160558
private function loadValidatorLoader(string $entityManagerName, ContainerBuilder $container) : void
    {
        if (! interface_exists(LoaderInterface::class) || ! class_exists(DoctrineLoader::class)) {
            return;
        }

        $validatorLoaderDefinition = $container->register(sprintf('doctrine.orm.%s_entity_manager.validator_loader', $entityManagerName), DoctrineLoader::class);
        $validatorLoaderDefinition->addArgument(new Reference(sprintf('doctrine.orm.%s_entity_manager', $entityManagerName)));

        $validatorLoaderDefinition->addTag('validator.auto_mapper', ['priority' => -100]);
    }
222210
public function load(ObjectManager $manager)
    {
        $windowMaker = new HubWindowMaker();
        $windowMaker->setHub($this->getReference('sam-hub'));
        $windowMaker->setDeliveryType(HubWindow::DELIVERY_TYPE_PICKUP);
        $windowMaker->setDayOfWeekNumber(6);
        $windowMaker->setStartTime('09:00');
        $windowMaker->setEndTime('11:00');

        $manager->persist($windowMaker);
        $manager->flush();

        $windowMaker = new HubWindowMaker();
        $windowMaker->setHub($this->getReference('sam-hub'));
        $windowMaker->setDeliveryType(HubWindow::DELIVERY_TYPE_PICKUP);
        $windowMaker->setDayOfWeekNumber(6);
        $windowMaker->setStartTime('11:00');
        $windowMaker->setEndTime('13:00');

        $manager->persist($windowMaker);
        $manager->flush();


        $windowMaker = new HubWindowMaker();
        $windowMaker->setHub($this->getReference('nick-hub'));
        $windowMaker->setDeliveryType(HubWindow::DELIVERY_TYPE_PICKUP);
        $windowMaker->setDayOfWeekNumber(6);
        $windowMaker->setStartTime('09:00');
        $windowMaker->setEndTime('11:00');

        $manager->persist($windowMaker);
        $manager->flush();

        $windowMaker = new HubWindowMaker();
        $windowMaker->setHub($this->getReference('nick-hub'));
        $windowMaker->setDeliveryType(HubWindow::DELIVERY_TYPE_PICKUP);
        $windowMaker->setDayOfWeekNumber(6);
        $windowMaker->setStartTime('11:00');
        $windowMaker->setEndTime('13:00');

        $manager->persist($windowMaker);
        $manager->flush();


        $windowMaker = new HubWindowMaker();
        $windowMaker->setHub($this->getReference('ramon-hub'));
        $windowMaker->setDeliveryType(HubWindow::DELIVERY_TYPE_PICKUP);
        $windowMaker->setDayOfWeekNumber(6);
        $windowMaker->setStartTime('09:00');
        $windowMaker->setEndTime('11:00');

        $manager->persist($windowMaker);
        $manager->flush();

        $windowMaker = new HubWindowMaker();
        $windowMaker->setHub($this->getReference('ramon-hub'));
        $windowMaker->setDeliveryType(HubWindow::DELIVERY_TYPE_PICKUP);
        $windowMaker->setDayOfWeekNumber(6);
        $windowMaker->setStartTime('11:00');
        $windowMaker->setEndTime('13:00');

        $manager->persist($windowMaker);
        $manager->flush();
    }
726827
protected function loadManager()
    {
        if (null === $this->getManager()) {
            $manager = new Manager($this->getConfig(), $this);
            $this->setManager($manager);
        } else {
            $manager = $this->getManager();
            $manager->setCommand($this);
        }
    }
282637
public function load(ObjectManager $manager)
    {
        /**
         * @var ObjectDirector $menuDirector
         */
        $menuDirector = $this->getDirector('menu');

        /**
         * Admin menu.
         */
        $menuAdmin = $menuDirector
            ->create()
            ->setCode('menu-admin')
            ->setEnabled(true)
            ->addSubnode($this->getReference('menu-node-vogue'));

        $menuDirector->save($menuAdmin);
        $this->addReference('menu-admin', $menuAdmin);

        /**
         * Front menu.
         */
        $menuFront = $menuDirector
            ->create()
            ->setCode('menu-front')
            ->setEnabled(true)
            ->addSubnode($this->getReference('menu-node-him'))
            ->addSubnode($this->getReference('menu-node-her'));

        $menuDirector->save($menuFront);
        $this->addReference('menu-front', $menuFront);
    }
1213023
public function load(ObjectManager $manager)
    {
        $gal = new Folder();
        $gal->setRel(Folder::TYPE_MEDIA);
        $gal->setName('Media');
        $gal->setTranslatableLocale('en');
        $manager->persist($gal);
        $manager->flush();
        $this->addReference('media-folder-en', $gal);

        $gal->setTranslatableLocale('nl');
        $manager->refresh($gal);
        $gal->setName('Media');
        $manager->persist($gal);
        $manager->flush();

        $gal->setTranslatableLocale('fr');
        $manager->refresh($gal);
        $gal->setName('Média');
        $manager->persist($gal);
        $manager->flush();

        $subgal = new Folder();
        $subgal->setParent($gal);
        $subgal->setRel(Folder::TYPE_IMAGE);
        $subgal->setName('Images');
        $subgal->setTranslatableLocale('en');
        $manager->persist($subgal);
        $manager->flush();
        $this->addReference('images-folder-en', $subgal);

        $subgal->setTranslatableLocale('nl');
        $manager->refresh($subgal);
        $subgal->setName('Afbeeldingen');
        $manager->persist($subgal);
        $manager->flush();

        $subgal->setTranslatableLocale('fr');
        $manager->refresh($subgal);
        $subgal->setName('Images');
        $manager->persist($subgal);
        $manager->flush();

        $subgal = new Folder();
        $subgal->setParent($gal);
        $subgal->setRel(Folder::TYPE_FILES);
        $subgal->setName('Files');
        $subgal->setTranslatableLocale('en');
        $manager->persist($subgal);
        $manager->flush();
        $this->addReference('files-folder-en', $subgal);

        $subgal->setTranslatableLocale('nl');
        $manager->refresh($subgal);
        $subgal->setName('Bestanden');
        $manager->persist($subgal);
        $manager->flush();

        $subgal->setTranslatableLocale('fr');
        $manager->refresh($subgal);
        $subgal->setName('Fichiers');
        $manager->persist($subgal);
        $manager->flush();

        $subgal = new Folder();
        $subgal->setParent($gal);
        $subgal->setRel(Folder::TYPE_SLIDESHOW);
        $subgal->setName('Slides');
        $subgal->setTranslatableLocale('en');
        $manager->persist($subgal);
        $manager->flush();
        $this->addReference('slides-folder-en', $subgal);

        $subgal->setTranslatableLocale('nl');
        $manager->refresh($subgal);
        $subgal->setName('Presentaties');
        $manager->persist($subgal);
        $manager->flush();

        $subgal->setTranslatableLocale('fr');
        $manager->refresh($subgal);
        $subgal->setName('Presentations');
        $manager->persist($subgal);
        $manager->flush();

        $subgal = new Folder();
        $subgal->setParent($gal);
        $subgal->setRel(Folder::TYPE_VIDEO);
        $subgal->setName('Videos');
        $subgal->setTranslatableLocale('en');
        $manager->persist($subgal);
        $manager->flush();
        $this->addReference('videos-folder-en', $subgal);

        $subgal->setTranslatableLocale('nl');
        $manager->refresh($subgal);
        $subgal->setName('Video\'s');
        $manager->persist($subgal);
        $manager->flush();

        $subgal->setTranslatableLocale('fr');
        $manager->refresh($subgal);
        $subgal->setName('Vidéos');
        $manager->persist($subgal);
        $manager->flush();
    }
1111336
public function loaderModels(ClassMetadata $class, $manager, array $ids, \Closure $stacker)
    {
        $classOfManagerName = $class->getFieldMapping($manager);

        $pool       = $this->manager->getPool();
        $methodFind = $classOfManagerName->getRepositoryMethod();

        $repository = $pool->getManager($manager)->getRepository($classOfManagerName->getName());

        if ($methodFind && method_exists($repository, $methodFind)) {
            foreach ($repository->$methodFind($ids) as $object) {
                $id = $class->getIdentifierValue($object);

                $stacker($id, $object);
            }
        } else {
            trigger_error(sprintf('findOneBy in ModelPersister::loadAll context is depreciate. Define repository-method for "%s" manager model, see mapping for "%s".', $manager, $class->getName()), E_USER_DEPRECATED);

            $repository = $pool->getManager($manager)->getRepository($classOfManagerName->getName());
            $field      = $class->getIdentifierReference($manager)->field;

            foreach ($ids as $id) {
                $object = $repository->findOneBy(array($field => $id));

                if (!$object) {
                    continue;
                }

                $id = $class->getIdentifierValue($object, $manager);

                $stacker($id, $object);
            }
        }
    }
1302050
public function load(ObjectManager $manager)
    {
        $geocoder = new \HarvestCloud\GeoBundle\Util\GoogleGeocoder();

        $user = new User();
        $user->setEmail('sam.hub@example.com');
        $user->setFirstname('Sam');
        $user->setLastname('Hub');
        $user->setEnabled(true);

        $encoder = $this->container
            ->get('security.encoder_factory')
            ->getEncoder($user)
        ;

        $user->setPassword($encoder->encodePassword('hub', $user->getSalt()));

        $profile = new Profile();
        $profile->setName($user->getFullname());
        $profile->setSystemHubStatus(Profile::STATUS_ENABLED);
        $profile->setHubStatus(Profile::STATUS_ACTIVE);

        $user->addProfile($profile);

        $location = new Location();
        $location->setName('Default');
        $location->setAddressLine1('100 East Street');
        $location->setTown('Great Barrington');
        $location->setStateCode('MA');
        $location->setPostalCode('01230');

        $geocoder->geocode($location);

        $profile->addLocation($location);

        $manager->persist($user);
        $manager->flush();

        $this->addReference('sam-hub', $profile);


        $user = new User();
        $user->setEmail('nick.hub@example.com');
        $user->setFirstname('Nick');
        $user->setLastname('Hub');
        $user->setEnabled(true);

        $encoder = $this->container
            ->get('security.encoder_factory')
            ->getEncoder($user)
        ;

        $user->setPassword($encoder->encodePassword('hub', $user->getSalt()));

        $profile = new Profile();
        $profile->setName($user->getFullname());
        $profile->setSystemHubStatus(Profile::STATUS_ENABLED);
        $profile->setHubStatus(Profile::STATUS_ACTIVE);

        $user->addProfile($profile);

        $location = new Location();
        $location->setName('Default');
        $location->setAddressLine1('100 Main Street');
        $location->setTown('Stockbridge');
        $location->setStateCode('MA');
        $location->setPostalCode('01262');

        $geocoder->geocode($location);

        $profile->addLocation($location);

        $manager->persist($user);
        $manager->flush();

        $this->addReference('nick-hub', $profile);


        $user = new User();
        $user->setEmail('ramon.hub@example.com');
        $user->setFirstname('Ramon');
        $user->setLastname('Hub');
        $user->setEnabled(true);

        $encoder = $this->container
            ->get('security.encoder_factory')
            ->getEncoder($user)
        ;

        $user->setPassword($encoder->encodePassword('hub', $user->getSalt()));

        $profile = new Profile();
        $profile->setName($user->getFullname());
        $profile->setSystemHubStatus(Profile::STATUS_ENABLED);
        $profile->setHubStatus(Profile::STATUS_ACTIVE);

        $user->addProfile($profile);

        $location = new Location();
        $location->setName('Default');
        $location->setAddressLine1('10 East Street');
        $location->setTown('Lenox');
        $location->setStateCode('MA');
        $location->setPostalCode('01240');

        $geocoder->geocode($location);

        $profile->addLocation($location);

        $manager->persist($user);
        $manager->flush();

        $this->addReference('ramon-hub', $profile);
    }
889920
public function load(ObjectManager $manager)
    {
        // Assumes first user is admin user
        $user = $manager->find('OrkestraApplicationBundle:User', 1);

        $author = new Author();
        $author->setUser($user);
        $manager->persist($author);

        $menu = new Menu();
        $menu->setName('main_nav');
        $menu->setType('main_nav');
        $menu->setDefinition($this->getMainNavDefinition());
        $manager->persist($menu);

        $manager->flush();
    }