Load data fixtures with the passed EntityManager.

@param ObjectManager $manager
18909
public function load(ObjectManager $manager)
    {
        $em = $this->container->get('doctrine.orm.entity_manager');

        $pageCreator = $this->container->get('kunstmaan_node.page_creator_service');

        $nodeRepo = $em->getRepository('KunstmaanNodeBundle:Node');
        $homePage = $nodeRepo->findOneBy(array('internalName' => 'homepage'));

        $sitemapPage = new SitemapPage();
        $sitemapPage->setTitle('Sitemap');

	$locales = explode('|', $this->container->getParameter('requiredlocales'));
        $translations = array();
	foreach ($locales as $locale) {
	    $translations[] = array('language' => $locale, 'callback' => function($page, $translation, $seo) {
		$translation->setTitle('Sitemap');
		$translation->setSlug('sitemap');
		$translation->setWeight(100);
	    });
	}

        $options = array(
            'parent' => $homePage,
            'page_internal_name' => 'sitemap',
            'set_online' => true,
            'hidden_from_nav' => true,
            'creator' => 'admin'
        );

        $pageCreator->createPage($sitemapPage, $translations, $options);
    }
912824
protected function loadOrmCacheDrivers(array $entityManager, ContainerBuilder $container)
    {
        $this->loadCacheDriver('metadata_cache', $entityManager['name'], $entityManager['metadata_cache_driver'], $container);
        $this->loadCacheDriver('result_cache', $entityManager['name'], $entityManager['result_cache_driver'], $container);
        $this->loadCacheDriver('query_cache', $entityManager['name'], $entityManager['query_cache_driver'], $container);
    }
792387
public function load(ObjectManager $objectManager)
    {
        /**
         * @var ObjectDirector $attributeDirector
         * @var ObjectDirector $attributeValueDirector
         */
        $attributeDirector = $this->getDirector('attribute');
        $attributeValueDirector = $this->getDirector('attribute_value');

        /**
         * Sizes.
         */
        $sizeAttribute = $attributeDirector
            ->create()
            ->setName('Size')
            ->setEnabled(true);

        $attributeDirector->save($sizeAttribute);
        $this->addReference('attribute-size', $sizeAttribute);

        $smallValue = $attributeValueDirector
            ->create()
            ->setValue('Small')
            ->setAttribute($sizeAttribute);

        $attributeValueDirector->save($smallValue);
        $this->addReference('value-size-small', $smallValue);

        $mediumValue = $attributeValueDirector
            ->create()
            ->setValue('Medium')
            ->setAttribute($sizeAttribute);

        $attributeValueDirector->save($mediumValue);
        $this->addReference('value-size-medium', $mediumValue);

        $largeValue = $attributeValueDirector
            ->create()
            ->setValue('Large')
            ->setAttribute($sizeAttribute);

        $attributeValueDirector->save($largeValue);
        $this->addReference('value-size-large', $largeValue);

        /**
         * Colors.
         */
        $colorAttribute = $attributeDirector
            ->create()
            ->setName('Color')
            ->setEnabled(true);

        $attributeDirector->save($colorAttribute);
        $this->addReference('attribute-color', $colorAttribute);

        $blueValue = $attributeValueDirector
            ->create()
            ->setValue('Blue')
            ->setAttribute($colorAttribute);

        $attributeValueDirector->save($blueValue);
        $this->addReference('value-color-blue', $blueValue);

        $whiteValue = $attributeValueDirector
            ->create()
            ->setValue('White')
            ->setAttribute($colorAttribute);

        $attributeValueDirector->save($whiteValue);
        $this->addReference('value-color-white', $whiteValue);

        $redValue = $attributeValueDirector
            ->create()
            ->setValue('Red')
            ->setAttribute($colorAttribute);

        $attributeValueDirector->save($redValue);
        $this->addReference('value-color-red', $redValue);
    }
1291685
public function load(ObjectManager $manager)
    {
        $tabletApp = new App;
        $tabletApp->setId('tablet');
        $tabletApp->setName(Translatable::createFromOriginalString('Tablet'));
        $tabletApp->setShowInMenu(true);
        $tabletApp->setOrder(1);

        $manager->persist($tabletApp);

        $adminApp = new App;
        $adminApp->setId('admin');
        $adminApp->setName(Translatable::createFromOriginalString('Administration'));
        $adminApp->setShowInMenu(true);
        $adminApp->setOrder(2);

        $manager->persist($adminApp);

        $manager->flush();
    }
817333
protected function loadOrmEntityManager(array $entityManager, ContainerBuilder $container)
    {
        $ormConfigDef = $container->setDefinition(sprintf('doctrine.orm.%s_configuration', $entityManager['name']), new ChildDefinition('doctrine.orm.configuration'));

        $this->loadOrmEntityManagerMappingInformation($entityManager, $ormConfigDef, $container);
        $this->loadOrmCacheDrivers($entityManager, $container);

        if (isset($entityManager['entity_listener_resolver']) && $entityManager['entity_listener_resolver']) {
            $container->setAlias(sprintf('doctrine.orm.%s_entity_listener_resolver', $entityManager['name']), $entityManager['entity_listener_resolver']);
        } else {
            $definition = new Definition('%doctrine.orm.entity_listener_resolver.class%');
            $definition->addArgument(new Reference('service_container'));
            $container->setDefinition(sprintf('doctrine.orm.%s_entity_listener_resolver', $entityManager['name']), $definition);
        }

        $methods = [
            'setMetadataCacheImpl' => new Reference(sprintf('doctrine.orm.%s_metadata_cache', $entityManager['name'])),
            'setQueryCacheImpl' => new Reference(sprintf('doctrine.orm.%s_query_cache', $entityManager['name'])),
            'setResultCacheImpl' => new Reference(sprintf('doctrine.orm.%s_result_cache', $entityManager['name'])),
            'setMetadataDriverImpl' => new Reference('doctrine.orm.' . $entityManager['name'] . '_metadata_driver'),
            'setProxyDir' => '%doctrine.orm.proxy_dir%',
            'setProxyNamespace' => '%doctrine.orm.proxy_namespace%',
            'setAutoGenerateProxyClasses' => '%doctrine.orm.auto_generate_proxy_classes%',
            'setClassMetadataFactoryName' => $entityManager['class_metadata_factory_name'],
            'setDefaultRepositoryClassName' => $entityManager['default_repository_class'],
            'setNamingStrategy' => new Reference($entityManager['naming_strategy']),
            'setQuoteStrategy' => new Reference($entityManager['quote_strategy']),
            'setEntityListenerResolver' => new Reference(sprintf('doctrine.orm.%s_entity_listener_resolver', $entityManager['name'])),
        ];

        $listenerId        = sprintf('doctrine.orm.%s_listeners.attach_entity_listeners', $entityManager['name']);
        $listenerDef       = $container->setDefinition($listenerId, new Definition('%doctrine.orm.listeners.attach_entity_listeners.class%'));
        $listenerTagParams = ['event' => 'loadClassMetadata'];
        if (isset($entityManager['connection'])) {
            $listenerTagParams['connection'] = $entityManager['connection'];
        }
        $listenerDef->addTag('doctrine.event_listener', $listenerTagParams);

        if (isset($entityManager['second_level_cache'])) {
            $this->loadOrmSecondLevelCache($entityManager, $ormConfigDef, $container);
        }

        if ($entityManager['repository_factory']) {
            $methods['setRepositoryFactory'] = new Reference($entityManager['repository_factory']);
        }

        foreach ($methods as $method => $arg) {
            $ormConfigDef->addMethodCall($method, [$arg]);
        }

        foreach ($entityManager['hydrators'] as $name => $class) {
            $ormConfigDef->addMethodCall('addCustomHydrationMode', [$name, $class]);
        }

        if (! empty($entityManager['dql'])) {
            foreach ($entityManager['dql']['string_functions'] as $name => $function) {
                $ormConfigDef->addMethodCall('addCustomStringFunction', [$name, $function]);
            }
            foreach ($entityManager['dql']['numeric_functions'] as $name => $function) {
                $ormConfigDef->addMethodCall('addCustomNumericFunction', [$name, $function]);
            }
            foreach ($entityManager['dql']['datetime_functions'] as $name => $function) {
                $ormConfigDef->addMethodCall('addCustomDatetimeFunction', [$name, $function]);
            }
        }

        $enabledFilters    = [];
        $filtersParameters = [];
        foreach ($entityManager['filters'] as $name => $filter) {
            $ormConfigDef->addMethodCall('addFilter', [$name, $filter['class']]);
            if ($filter['enabled']) {
                $enabledFilters[] = $name;
            }
            if (! $filter['parameters']) {
                continue;
            }

            $filtersParameters[$name] = $filter['parameters'];
        }

        $managerConfiguratorName = sprintf('doctrine.orm.%s_manager_configurator', $entityManager['name']);
        $container
            ->setDefinition($managerConfiguratorName, new ChildDefinition('doctrine.orm.manager_configurator.abstract'))
            ->replaceArgument(0, $enabledFilters)
            ->replaceArgument(1, $filtersParameters);

        if (! isset($entityManager['connection'])) {
            $entityManager['connection'] = $this->defaultConnection;
        }

        $container
            ->setDefinition(sprintf('doctrine.orm.%s_entity_manager', $entityManager['name']), new ChildDefinition('doctrine.orm.entity_manager.abstract'))
            ->setPublic(true)
            ->setArguments([
                new Reference(sprintf('doctrine.dbal.%s_connection', $entityManager['connection'])),
                new Reference(sprintf('doctrine.orm.%s_configuration', $entityManager['name'])),
            ])
            ->setConfigurator([new Reference($managerConfiguratorName), 'configure']);

        $container->setAlias(
            sprintf('doctrine.orm.%s_entity_manager.event_manager', $entityManager['name']),
            new Alias(sprintf('doctrine.dbal.%s_connection.event_manager', $entityManager['connection']), false)
        );

        if (! isset($entityManager['entity_listeners'])) {
            return;
        }

        if (! isset($listenerDef)) {
            throw new InvalidArgumentException('Entity listeners configuration requires doctrine-orm 2.5.0 or newer');
        }

        $entities = $entityManager['entity_listeners']['entities'];

        foreach ($entities as $entityListenerClass => $entity) {
            foreach ($entity['listeners'] as $listenerClass => $listener) {
                foreach ($listener['events'] as $listenerEvent) {
                    $listenerEventName = $listenerEvent['type'];
                    $listenerMethod    = $listenerEvent['method'];

                    $listenerDef->addMethodCall('addEntityListener', [
                        $entityListenerClass,
                        $listenerClass,
                        $listenerEventName,
                        $listenerMethod,
                    ]);
                }
            }
        }
    }
191807
public function load(ObjectManager $manager)
    {
        $exchange = new Exchange();
        $exchange->setName('The Harvest Cloud');

        $manager->persist($exchange);
        $manager->flush();
    }
48487
public function load(ObjectManager $manager)
    {
        $howManyApps = 15;
        $createdCount = 0;

        while ($createdCount < $howManyApps) {
            $app = new App;
            $app->setId('app'.$createdCount);
            $app->setName('App'.$createdCount);
            $app->setShowInMenu(true);
            $app->setOrder($createdCount);

            $manager->persist($app);
            $createdCount++;
        }

        $manager->flush();
    }
323259
public function afterInitialize(Event $event, ModelsManager $manager, $model)
    {
        //Reflector
        /** @var \Phalcon\Annotations\Reflection $reflector */
        $reflector = $this->annotations->get($model);
        /**
         * Read the annotations in the class' docblock
         */
        $annotations = $reflector->getClassAnnotations();
        if ($annotations) {
            /**
             * Traverse the annotations
             */
            foreach ($annotations as $annotation) {
                switch ($annotation->getName()) {
                    /**
                     * Initializes the model's source
                     */
                    case 'Source':
                        $arguments = $annotation->getArguments();
                        $model->setConnectionService($arguments[0]);
                        $manager->setModelSource($model, $arguments[1]);
                        break;
                    /**
                     * Initializes Has-Many relations
                     */
                    case 'HasMany':
                        $arguments = $annotation->getArguments();
                        if (!isset($arguments[3])) {
                            $arguments[3] = null;
                        }
                        $manager->addHasMany($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
                        break;
                    /**
                     * Initializes Has-Many-To-Many relations
                     */
                    case 'HasManyToMany':
                        $arguments = $annotation->getArguments();
                        if (!isset($arguments[6])) {
                            $arguments[6] = null;
                        }
                        $manager->addHasManyToMany($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5], $arguments[6]);
                        break;
                    /**
                     * Initializes Has-One relations
                     */
                    case 'HasOne':
                        $arguments = $annotation->getArguments();
                        if (!isset($arguments[3])) {
                            $arguments[3] = null;
                        }
                        $manager->addHasOne($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
                        break;
                    /**
                     * Initializes Has-Many relations
                     */
                    case 'BelongsTo':
                        $arguments = $annotation->getArguments();
                        if (!isset($arguments[3])) {
                            $arguments[3] = null;
                        }
                        $manager->addBelongsTo($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
                        break;
                }
            }
        }
    }
666071
public function load(ObjectManager $manager)
    {
        $translator = $this->container->get('translator');
        $infoName = $translator->trans('informations', array(), 'platform');

        $desktopHomeTab = new HomeTab();
        $desktopHomeTab->setType('admin_desktop');
        $desktopHomeTab->setName($infoName);
        $manager->persist($desktopHomeTab);

        $desktopHomeTabConfig = new HomeTabConfig();
        $desktopHomeTabConfig->setHomeTab($desktopHomeTab);
        $desktopHomeTabConfig->setType('admin_desktop');
        $desktopHomeTabConfig->setVisible(true);
        $desktopHomeTabConfig->setLocked(false);
        $desktopHomeTabConfig->setTabOrder(1);
        $manager->persist($desktopHomeTabConfig);

        $workspaceHomeTab = new HomeTab();
        $workspaceHomeTab->setType('admin_workspace');
        $workspaceHomeTab->setName($infoName);
        $manager->persist($workspaceHomeTab);

        $workspaceHomeTabConfig = new HomeTabConfig();
        $workspaceHomeTabConfig->setHomeTab($workspaceHomeTab);
        $workspaceHomeTabConfig->setType('admin_workspace');
        $workspaceHomeTabConfig->setVisible(true);
        $workspaceHomeTabConfig->setLocked(false);
        $workspaceHomeTabConfig->setTabOrder(1);
        $manager->persist($workspaceHomeTabConfig);
    }
1232975
public function setEntityManager(EntityManager $em)
    {
        if ($this->em !== null) {
            throw new \LogicException('Entity manager can only be set before any results are fetched');
        }

        $this->em = $em;
    }
1046447
public function addToManager(Manager $manager)
    {
        $this->extend('onBeforeAddToManager', $manager);
        $scaffold = $this->scaffold($manager);
        if (!$manager->hasType($this->getTypeName())) {
            $manager->addType($scaffold, $this->getTypeName());
        }

        foreach ($this->operations as $op) {
            $op->addToManager($manager);
        }

        foreach ($this->nestedQueries as $scaffold) {
            $scaffold->addToManager($manager);
        }

        $this->extend('onAfterAddToManager', $manager);
    }
1128509
public function init(ModuleManagerInterface $manager)
    {
        if (!$manager instanceof ModuleManager) {
            $errMsg =sprintf('Module manager not implement %s', ModuleManager::class);
            throw new Exception\InvalidArgumentException($errMsg);
        }

        
        /** @var ServiceLocatorInterface $sm */
        $sm = $manager->getEvent()->getParam('ServiceManager');

        if (!$sm instanceof ServiceLocatorInterface) {
            $errMsg = sprintf('Service locator not implement %s', ServiceLocatorInterface::class);
            throw new Exception\InvalidArgumentException($errMsg);
        }
        /** @var ServiceListenerInterface $serviceListener */
        $serviceListener = $sm->get('ServiceListener');
        if (!$serviceListener instanceof ServiceListenerInterface) {
            $errMsg = sprintf('ServiceListener not implement %s', ServiceListenerInterface::class);
            throw new Exception\InvalidArgumentException($errMsg);
        }


        $serviceListener->addServiceManager(
            EntryNameResolverManagerInterface::class,
            EntryNameResolverManager::CONFIG_KEY,
            EntryNameResolverProviderInterface::class,
            'getEntryNameResolverConfig'
        );

    }
403614
public function getLoader(ObjectManager $manager, $queryBuilder, $class, $hints = [])
    {
        $loader = new ORMQueryBuilderLoader($queryBuilder, $manager, $class);

        foreach ($hints as $name => $value) {
            $loader->setHint($name, $value);
        }

        return $loader;
    }
456959
public function load(ObjectManager $objectManager)
    {
        /**
         * @var ObjectDirector $zoneDirector
         */
        $zoneDirector = $this->getDirector('zone');

        $zone08021 = $zoneDirector
            ->create()
            ->setName('Postalcode 08021')
            ->setCode('zone-08021')
            ->addLocation($this->getReference('location-sant-celoni'))
            ->addLocation($this->getReference('location-08021'));

        $this->setReference('zone-08021', $zone08021);
        $zoneDirector->save($zone08021);

        $zoneViladecavalls = $zoneDirector
            ->create()
            ->setName('Viladecavalls i alrededores')
            ->setCode('zone-viladecavalls')
            ->addLocation($this->getReference('location-viladecavalls'));

        $this->setReference('zone-viladecavalls', $zoneViladecavalls);
        $zoneDirector->save($zoneViladecavalls);
    }
741745
public function load(ObjectManager $manager)
    {
        $user = new User();
        $user->setFirstname('admin');
        $user->setFirstname('admin');
        $user->setUsername('admin');
        $user->setEmail('admin@test.com');
        $user->setState(1);

        $newPass = 'playground';

        $bcrypt = new Bcrypt;
        $bcrypt->setCost(14);

        $pass = $bcrypt->create($newPass);
        $user->setPassword($pass);

        $user->addRole(
            $this->getReference('admin-role') // load the stored reference
        );

        $manager->persist($user);

        $manager->flush();

        $user = new User();
        $user->setFirstname('supervisor');
        $user->setFirstname('supervisor');
        $user->setUsername('supervisor');
        $user->setEmail('supervisor@test.com');
        $user->setState(1);

        $newPass = 'playground';

        $bcrypt = new Bcrypt;
        $bcrypt->setCost(14);

        $pass = $bcrypt->create($newPass);
        $user->setPassword($pass);

        $user->addRole(
            $this->getReference('supervisor-role') // load the stored reference
        );

        $manager->persist($user);

        $manager->flush();

        $user = new User();
        $user->setFirstname('game-manager');
        $user->setFirstname('game-manager');
        $user->setUsername('gamemanager');
        $user->setEmail('game-manager@test.com');
        $user->setState(1);

        $newPass = 'playground';

        $bcrypt = new Bcrypt;
        $bcrypt->setCost(14);

        $pass = $bcrypt->create($newPass);
        $user->setPassword($pass);

        $user->addRole(
            $this->getReference('game-role') // load the stored reference
        );

        $manager->persist($user);

        $manager->flush();
    }
851441
public function setConnectionManager(ManagerInterface $manager)
    {
        $this->connectionManager = $manager;
        foreach ($this->servers as $server) {
            $this->connectionManager->addServer($server);
        }
    }
1221116
public function load(ObjectManager $manager)
    {
        $product = new Product();
        $product->setName('Lovely Eggs');
        $product->setCategory($this->getReference('eggs-category'));
        $product->setSeller($this->getReference('jon-seller'));
        $product->setInitialQuantity(10);
        $product->setPrice('5.00');

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


        $product = new Product();
        $product->setName('Tomatoes');
        $product->setCategory($this->getReference('tomatoes-category'));
        $product->setSeller($this->getReference('jon-seller'));
        $product->setInitialQuantity(7);
        $product->setPrice('3.85');

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


        $product = new Product();
        $product->setName('Suh-weet Potatoes');
        $product->setCategory($this->getReference('sweet-potatoes-category'));
        $product->setSeller($this->getReference('tom-seller'));
        $product->setInitialQuantity(12);
        $product->setPrice('2.75');

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


        $product = new Product();
        $product->setName('Tom\'s Toms');
        $product->setCategory($this->getReference('tomatoes-category'));
        $product->setSeller($this->getReference('tom-seller'));
        $product->setInitialQuantity(8);
        $product->setPrice('4.75');

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


        $product = new Product();
        $product->setName('Apples');
        $product->setCategory($this->getReference('apples-category'));
        $product->setSeller($this->getReference('jo-seller'));
        $product->setInitialQuantity(13);
        $product->setPrice('5.05');

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


        $product = new Product();
        $product->setName('Sweet Potatoes');
        $product->setCategory($this->getReference('sweet-potatoes-category'));
        $product->setSeller($this->getReference('jo-seller'));
        $product->setInitialQuantity(13);
        $product->setPrice('2.65');

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


        $product = new Product();
        $product->setName('Carrots');
        $product->setCategory($this->getReference('carrots-category'));
        $product->setSeller($this->getReference('jo-seller'));
        $product->setInitialQuantity(15);
        $product->setPrice('2.95');

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


        $product = new Product();
        $product->setName('Onions');
        $product->setCategory($this->getReference('onions-category'));
        $product->setSeller($this->getReference('sterling-seller'));
        $product->setInitialQuantity(11);
        $product->setPrice('2.95');

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


        $product = new Product();
        $product->setName('Ca-ca-carrots');
        $product->setCategory($this->getReference('carrots-category'));
        $product->setSeller($this->getReference('sterling-seller'));
        $product->setInitialQuantity(1);
        $product->setPrice('2.90');

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


        $product = new Product();
        $product->setName('Apples');
        $product->setCategory($this->getReference('apples-category'));
        $product->setSeller($this->getReference('sterling-seller'));
        $product->setInitialQuantity(11);
        $product->setPrice('4.15');

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


        $product = new Product();
        $product->setName('Them Apples');
        $product->setCategory($this->getReference('apples-category'));
        $product->setSeller($this->getReference('tom-seller'));
        $product->setInitialQuantity(11);
        $product->setPrice('4.25');

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


        $product = new Product();
        $product->setName('Delicious Eggs');
        $product->setCategory($this->getReference('eggs-category'));
        $product->setSeller($this->getReference('tom-seller'));
        $product->setInitialQuantity(8);
        $product->setPrice('5.25');

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


        $product = new Product();
        $product->setName('Yummy Eggs');
        $product->setCategory($this->getReference('eggs-category'));
        $product->setSeller($this->getReference('stephen-seller'));
        $product->setInitialQuantity(11);
        $product->setPrice('4.95');

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


        $product = new Product();
        $product->setName('Milk');
        $product->setCategory($this->getReference('milk-category'));
        $product->setSeller($this->getReference('jon-seller'));
        $product->setInitialQuantity(8);
        $product->setPrice('3.55');

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


        $product = new Product();
        $product->setName('Milk');
        $product->setCategory($this->getReference('milk-category'));
        $product->setSeller($this->getReference('stephen-seller'));
        $product->setInitialQuantity(10);
        $product->setPrice('3.45');

        $manager->persist($product);
        $manager->flush();
    }