Load data fixtures with the passed EntityManager

@param ObjectManager $manager
324745
public function load(ObjectManager $manager)
    {
        $group1 = $this->createGroup($manager, 'Administrators', array(
            $this->getReference(RoleFixtures::REFERENCE_PERMISSIONMANAGER_ROLE),
            $this->getReference(RoleFixtures::REFERENCE_ADMIN_ROLE),
        ));

        $group2 = $this->createGroup($manager, 'Guests', array(
            $this->getReference(RoleFixtures::REFERENCE_GUEST_ROLE),
        ));

        $group3 = $this->createGroup($manager, 'Super administrators', array(
            $this->getReference(RoleFixtures::REFERENCE_PERMISSIONMANAGER_ROLE),
            $this->getReference(RoleFixtures::REFERENCE_ADMIN_ROLE),
            $this->getReference(RoleFixtures::REFERENCE_SUPERADMIN_ROLE),
        ));

        $manager->flush();

        $this->addReference(self::REFERENCE_ADMINS_GROUP, $group1);
        $this->addReference(self::REFERENCE_GUESTS_GROUP, $group2);
        $this->addReference(self::REFERENCE_SUPERADMINS_GROUP, $group3);
    }
24519
public function scaffold(Manager $manager)
    {
        return new ObjectType(
            [
                'name' => $this->getTypeName(),
                'fields' => function () use ($manager) {
                    return $this->createFields($manager);
                },
            ]
        );
    }
191807
public function load(ObjectManager $manager)
    {
        $exchange = new Exchange();
        $exchange->setName('The Harvest Cloud');

        $manager->persist($exchange);
        $manager->flush();
    }
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);
    }
726827
protected function loadManager()
    {
        if (null === $this->getManager()) {
            $manager = new Manager($this->getConfig(), $this);
            $this->setManager($manager);
        } else {
            $manager = $this->getManager();
            $manager->setCommand($this);
        }
    }
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);
    }
144993
private function resolveEntityManagerName(
        ContainerBuilder $container,
        string $entityManagerName
    ) {
        if (!$container->has('doctrine.orm.' . $entityManagerName . '_metadata_driver')) {
            throw new EntityManagerNotFoundException($entityManagerName);
        }
    }
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();
    }
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,
                    ]);
                }
            }
        }
    }
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);
    }
225653
public function load(ObjectManager $em) {
    $bridge = new DoctrineBridge($em);
    $bridge->beginTransaction();

    $nodes = $this->convertNodes($this->example->toParentPointerArray(), $em);

    foreach($nodes as $node) {
      $bridge->persist($node);
    }

    $bridge->commit();
    $em->flush();
  }
205316
public function load(ObjectManager $manager)
    {
        $geocoder = new \HarvestCloud\GeoBundle\Util\GoogleGeocoder();

        $user = new User();
        $user->setEmail('jon.seller@example.com');
        $user->setFirstname('Jon');
        $user->setLastname('Seller');
        $user->setEnabled(true);

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

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

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

        $user->addProfile($profile);

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

        $geocoder->geocode($location);

        $profile->addLocation($location);

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

        $this->addReference('jon-seller', $profile);


        $user = new User();
        $user->setEmail('tom.seller@example.com');
        $user->setFirstname('Tom');
        $user->setLastname('Seller');
        $user->setEnabled(true);

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

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

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

        $user->addProfile($profile);

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

        $geocoder->geocode($location);

        $profile->addLocation($location);

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

        $this->addReference('tom-seller', $profile);


        $user = new User();
        $user->setEmail('stephen.seller@example.com');
        $user->setFirstname('Stephen');
        $user->setLastname('Seller');
        $user->setEnabled(true);

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

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

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

        $user->addProfile($profile);

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

        $geocoder->geocode($location);

        $profile->addLocation($location);

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

        $this->addReference('stephen-seller', $profile);


        $user = new User();
        $user->setEmail('jo.seller@example.com');
        $user->setFirstname('Jo');
        $user->setLastname('Seller');
        $user->setEnabled(true);

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

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

        $profile = new Profile();
        $profile->setName($user->getFullname());
        $profile->setSystemSellerStatus(Profile::STATUS_ENABLED);
        $profile->setSellerStatus(Profile::STATUS_ACTIVE);
        $profile->setSlug('joseller');

        $user->addProfile($profile);

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

        $geocoder->geocode($location);

        $profile->addLocation($location);

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

        $this->addReference('jo-seller', $profile);


        $user = new User();
        $user->setEmail('mike.seller@example.com');
        $user->setFirstname('Mike');
        $user->setLastname('Seller');
        $user->setEnabled(true);

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

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

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

        $user->addProfile($profile);

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

        $geocoder->geocode($location);

        $profile->addLocation($location);

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

        $this->addReference('mike-seller', $profile);


        $user = new User();
        $user->setEmail('sterling.seller@example.com');
        $user->setFirstname('Sterling');
        $user->setLastname('Seller');
        $user->setEnabled(true);

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

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

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

        $user->addProfile($profile);

        $location = new Location();
        $location->setName('Default');
        $location->setAddressLine1('1 East Street');
        $location->setTown('Lee');
        $location->setStateCode('MA');
        $location->setPostalCode('01238');

        $geocoder->geocode($location);

        $profile->addLocation($location);

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

        $this->addReference('sterling-seller', $profile);
    }
447683
private function resetEntityManager()
    {
        $managers = $this->doctrine->getManagers();
        foreach ($managers as $name => $manager) {
            if (!$manager->getMetadataFactory()->isTransient($this->entityClass)) {
                $this->doctrine->resetManager($name);
                break;
            }
        }
    }
1365002
protected function loadMappingInformation(array $objectManager, ContainerBuilder $container)
    {
        if ($objectManager['auto_mapping']) {
            // automatically register bundle mappings
            foreach (array_keys($container->getParameter('kernel.bundles')) as $bundle) {
                if (!isset($objectManager['mappings'][$bundle])) {
                    $objectManager['mappings'][$bundle] = [
                        'mapping' => true,
                        'is_bundle' => true,
                    ];
                }
            }
        }

        foreach ($objectManager['mappings'] as $mappingName => $mappingConfig) {
            if (null !== $mappingConfig && false === $mappingConfig['mapping']) {
                continue;
            }

            $mappingConfig = array_replace([
                'dir' => false,
                'type' => false,
                'prefix' => false,
            ], (array) $mappingConfig);

            $mappingConfig['dir'] = $container->getParameterBag()->resolveValue($mappingConfig['dir']);
            // a bundle configuration is detected by realizing that the specified dir is not absolute and existing
            if (!isset($mappingConfig['is_bundle'])) {
                $mappingConfig['is_bundle'] = !is_dir($mappingConfig['dir']);
            }

            if ($mappingConfig['is_bundle']) {
                $bundle = null;
                foreach ($container->getParameter('kernel.bundles') as $name => $class) {
                    if ($mappingName === $name) {
                        $bundle = new \ReflectionClass($class);

                        break;
                    }
                }

                if (null === $bundle) {
                    throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled.', $mappingName));
                }

                $mappingConfig = $this->getMappingDriverBundleConfigDefaults($mappingConfig, $bundle, $container);
                if (!$mappingConfig) {
                    continue;
                }
            }

            $this->assertValidMappingConfiguration($mappingConfig, $objectManager['name']);
            $this->setMappingDriverConfig($mappingConfig, $mappingName);
            $this->setMappingDriverAlias($mappingConfig, $mappingName);
        }
    }
1255653
public function init( ModuleManagerInterface $manager )
    {
        $this->moduleManager  = $manager;
        $this->serviceLocator = $manager->getEvent()
                                        ->getParam( 'ServiceManager' );

        $shared = $manager->getEventManager()
                          ->getSharedManager();

        $shared->attach(
            'Zend\Stdlib\DispatchableInterface',
            MvcEvent::EVENT_DISPATCH,
            array( new InjectTemplateListener, 'injectTemplate' ),
            -85
        );

        $shared->attach(
         // 'Zend\Mvc\Controller\AbstractController',
            'Zend\Stdlib\DispatchableInterface',
            MvcEvent::EVENT_DISPATCH,
            array( $this, 'onDispatch' ),
            100
        );
    }
1252918
public function load(ObjectManager $manager)
    {
        $nodeRepository = $this->container->get('open_orchestra_model.repository.redirection');
        $nodes = $nodeRepository->findAll();
        $updateRoute = $this->container->get('open_orchestra_backoffice.manager.route_document');

        foreach ($nodes as $node) {
            $routes = $updateRoute->createOrUpdateForRedirection($node);
            foreach ($routes as $route) {
                $manager->persist($route);
            }
        }

        $manager->flush();
    }
169134
public function load(ObjectManager $manager)
    {
        /**
         * @var ProductInterface  $productWithVariants
         * @var CurrencyInterface $currency
         * @var ObjectDirector    $variantDirector
         */
        $currency = $this->getReference('currency-dollar');
        $productWithVariants = $this->getReference('product-with-variants');
        $variantDirector = $this->getDirector('product_variant');

        /**
         * @var ValueInterface $optionWhite
         * @var ValueInterface $optionRed
         * @var ValueInterface $optionSmall
         * @var ValueInterface $optionLarge
         */
        $optionWhite = $this->getReference('value-color-white');
        $optionRed = $this->getReference('value-color-red');
        $optionSmall = $this->getReference('value-size-small');
        $optionLarge = $this->getReference('value-size-large');

        /**
         * Variant White-Small.
         */
        $variantWhiteSmall = $variantDirector
            ->create()
            ->setSku('variant-white-small-sku')
            ->setStock(100)
            ->setProduct($productWithVariants)
            ->addOption($optionWhite)
            ->addOption($optionSmall)
            ->setPrice(Money::create(1500, $currency))
            ->setHeight(13)
            ->setWidth(12)
            ->setDepth(19)
            ->setWeight(125)
            ->setEnabled(true);

        $productWithVariants->setPrincipalVariant($variantWhiteSmall);

        $variantDirector->save($variantWhiteSmall);
        $this->addReference('variant-white-small', $variantWhiteSmall);

        /**
         * Variant White-Large.
         */
        $variantWhiteLarge = $variantDirector
            ->create()
            ->setSku('variant-white-large-sku')
            ->setStock(100)
            ->setProduct($productWithVariants)
            ->addOption($optionWhite)
            ->addOption($optionLarge)
            ->setPrice(Money::create(1800, $currency))
            ->setHeight(12)
            ->setWidth(11)
            ->setDepth(45)
            ->setWeight(155)
            ->setEnabled(true);

        $variantDirector->save($variantWhiteLarge);
        $this->addReference('variant-white-large', $variantWhiteLarge);

        /**
         * Variant Red-Small.
         */
        $variantRedSmall = $variantDirector
            ->create()
            ->setSku('variant-red-small-sku')
            ->setStock(100)
            ->setProduct($productWithVariants)
            ->addOption($optionRed)
            ->addOption($optionSmall)
            ->setPrice(Money::create(1500, $currency))
            ->setHeight(19)
            ->setWidth(9)
            ->setDepth(33)
            ->setWeight(1000)
            ->setEnabled(true);

        $this->storeProductImage(
            $variantRedSmall,
            'variant.jpg'
        );

        $variantDirector->save($variantRedSmall);
        $this->addReference('variant-red-small', $variantRedSmall);

        /**
         * Variant Red-Large.
         */
        $variantRedLarge = $variantDirector
            ->create()
            ->setSku('variant-red-large-sku')
            ->setStock(100)
            ->setProduct($productWithVariants)
            ->addOption($optionRed)
            ->addOption($optionLarge)
            ->setPrice(Money::create(1800, $currency))
            ->setHeight(50)
            ->setWidth(30)
            ->setDepth(18)
            ->setWeight(70)
            ->setEnabled(true);

        $variantDirector->save($variantRedLarge);
        $this->addReference('variant-red-large', $variantRedLarge);
    }