Setup the entity managers
@return array
548838
protected function setUpEntityManagers()
    {
        $managers    = [];
        $connections = [];

        foreach ($this->config['managers'] as $manager => $settings) {
            $managerName    = IlluminateRegistry::getManagerNamePrefix() . $manager;
            $connectionName = IlluminateRegistry::getConnectionNamePrefix() . $manager;

            // Bind manager
            $this->app->singleton($managerName, function () use ($settings) {

                $manager = EntityManager::create(
                    ConnectionManager::resolve(array_get($settings, 'connection')),
                    MetaDataManager::resolve(array_get($settings, 'meta'))
                );

                $configuration = $manager->getConfiguration();

                // Listeners
                if (isset($settings['events']['listeners'])) {
                    foreach ($settings['events']['listeners'] as $event => $listener) {
                        $manager->getEventManager()->addEventListener($event, $listener);
                    }
                }

                // Subscribers
                if (isset($settings['events']['subscribers'])) {
                    foreach ($settings['events']['subscribers'] as $subscriber) {
                        $manager->getEventManager()->addEventSubscriber($subscriber);
                    }
                }

                // Filters
                if (isset($settings['filters'])) {
                    foreach ($settings['filters'] as $name => $filter) {
                        $configuration->getMetadataDriverImpl()->addFilter($name, $filter);
                        $manager->getFilters()->enable($name);
                    }
                }

                // Paths
                $configuration->getMetadataDriverImpl()->addPaths(
                    array_get($settings, 'paths', [])
                );

                // Repository
                $configuration->setDefaultRepositoryClassName(
                    array_get($settings, 'repository', \Doctrine\ORM\EntityRepository::class)
                );

                $configuration->setAutoGenerateProxyClasses(
                    array_get($settings, 'proxies.auto_generate', false)
                );

                if ($namespace = array_get($settings, 'proxies.namespace', false)) {
                    $configuration->setProxyNamespace($namespace);
                }

                return $manager;
            });

            // Bind connection
            $this->app->singleton($connectionName, function ($app) use ($manager) {
                $app->make(IlluminateRegistry::getManagerNamePrefix() . $manager)->getConnection();
            });

            $managers[$manager]    = $manager;
            $connections[$manager] = $manager;
        }

        return [$managers, $connections];
    }
605768
protected function setupControllerMenus()
    {
        $this->config = Config::getInstance();

        $paths = Config::getInstance()->get('Octo.paths.namespaces');

        foreach ($paths as $namespace => $path) {
            $thisPath = $path . 'Admin/Controller/*.php';
            $files = glob($thisPath);

            foreach ($files as $file) {
                $this->getControllerMenuItems($file, $namespace);
            }
        }
    }
798971
protected function setupFacades()
    {
        // Setup alias loader.
        $loader = AliasLoader::getInstance();

        // Load Sentinel
        // - Activation
        // - Reminder
        // - Sentinel
        $loader->alias('Activation', Activation::class);
        $loader->alias('Reminder', Reminder::class);
        $loader->alias('Sentinel', Sentinel::class);

        // Load Flash
        $loader->alias('Flash', Flash::class);

        // Load Ekko
        $loader->alias('Ekko', Ekko::class);

        // Carbon
        $loader->alias('Carbon', Carbon::class);

        // Load Form
        // - Form
        // - BootForm
        $loader->alias('Form', Form::class);
        $loader->alias('BootForm', BootForm::class);
    }
659414
protected function _getSubManagers()
	{
		$list = array();
		$path = 'classes/catalog/manager/index/catalog/submanagers';

		foreach( $this->_getContext()->getConfig()->get( $path, array() ) as $domain ) {
			$list[$domain] = $this->getSubManager( $domain );
		}

		return $list;
	}
776585
protected function _setupModelInstances()
    {
        $this->_profileModel = $this->loadModel($this->getConfig('profileModel'));
        $this->_profileModel->belongsTo($this->getConfig('userModel'));

        $this->_userModel = $this->loadModel($this->getConfig('userModel'));
    }
814149
public function install()
    {
        PackageList::refreshCache();
        $em = $this->app->make(EntityManagerInterface::class);
        $package = new PackageEntity();
        $package->setPackageName($this->getPackageName());
        $package->setPackageDescription($this->getPackageDescription());
        $package->setPackageVersion($this->getPackageVersion());
        $package->setPackageHandle($this->getPackageHandle());
        $em->persist($package);
        $em->flush();

        $this->app->make('cache/overrides')->flush();

        $this->installDatabase();

        Localization::clearCache();

        return $package;
    }
726827
protected function loadManager()
    {
        if (null === $this->getManager()) {
            $manager = new Manager($this->getConfig(), $this);
            $this->setManager($manager);
        } else {
            $manager = $this->getManager();
            $manager->setCommand($this);
        }
    }
1192896
protected function initialize()
    {
        if (!$this->initialized) {
            $params = [];

            $sql  = 'SELECT MAX(' . $this->configuration->getRevisionFieldName() . ') as rev, ';
            $sql .= $this->configuration->getRevisionTypeFieldName() . ' AS revtype, ';
            $sql .= implode(', ', $this->metadata->getIdentifierColumnNames()) . ' ';
            if (isset($this->associationDefinition['indexBy'])) {
                $sql .= ', ' . $this->associationDefinition['indexBy'] . ' ';
            }
            $sql .= 'FROM ' . $this->configuration->getTableName($this->metadata) . ' t ';
            $sql .= 'WHERE ' . $this->configuration->getRevisionFieldName() . ' <= ' . $this->revision . ' ';

            foreach ($this->foreignKeys as $column => $value) {
                $sql .= 'AND ' . $column . ' = ? ';
                $params[] = $value;
            }

            //we check for revisions greater than current belonging to other entities
            $sql .= 'AND NOT EXISTS (SELECT * FROM ' . $this->configuration->getTableName($this->metadata) . ' st WHERE';

            //ids
            foreach ($this->metadata->getIdentifierColumnNames() as $name) {
                $sql .= ' st.' . $name . ' = t.' . $name . ' AND';
            }

            //foreigns
            $sql .= ' ((';

            //master entity query, not equals
            $notEqualParts = $nullParts = [];
            foreach ($this->foreignKeys as $column => $value) {
                $notEqualParts[] = $column . ' <> ?';
                $nullParts[]     = $column . ' IS NULL';
                $params[]        = $value;
            }

            $sql .= implode(' AND ', $notEqualParts) . ') OR (' . implode(' AND ', $nullParts) . '))';

            //revision
            $sql .= ' AND st.' . $this->configuration->getRevisionFieldName() . ' <= ' . $this->revision;
            $sql .= ' AND st.' . $this->configuration->getRevisionFieldName() . ' > t.' . $this->configuration->getRevisionFieldName();

            $sql .= ') ';
            //end of check for for belonging to other entities

            //check for deleted revisions older than requested
            $sql .= 'AND NOT EXISTS (SELECT * FROM ' . $this->configuration->getTableName($this->metadata) . ' sd WHERE';

            //ids
            foreach ($this->metadata->getIdentifierColumnNames() as $name) {
                $sql .= ' sd.' . $name . ' = t.' . $name . ' AND';
            }

            //revision
            $sql .= ' sd.' . $this->configuration->getRevisionFieldName() . ' <= ' . $this->revision;
            $sql .= ' AND sd.' . $this->configuration->getRevisionFieldName() . ' > t.' . $this->configuration->getRevisionFieldName();

            $sql .= ' AND sd.' . $this->configuration->getRevisionTypeFieldName() . ' = ?';
            $params[] = 'DEL';

            $sql .= ') ';
            //end check for deleted revisions older than requested

            $sql .= 'GROUP BY ' . implode(', ', $this->metadata->getIdentifierColumnNames()) ./*', '.$this->configuration->getRevisionTypeFieldName().*/
                    ' ';
            $sql .= 'HAVING ' . $this->configuration->getRevisionTypeFieldName() . ' <> ?';
            //add rev type parameter
            $params[] = 'DEL';

            $rows = $this->auditReader->getConnection()->fetchAll($sql, $params);

            foreach ($rows as $row) {
                $entity = [
                    'rev'     => $row['rev'],
                    'revtype' => $row['revtype'],
                ];

                unset($row['rev'], $row['revtype']);

                $entity['keys'] = $row;

                if (isset($this->associationDefinition['indexBy'])) {
                    $key = $row[$this->associationDefinition['indexBy']];
                    unset($entity['keys'][$this->associationDefinition['indexBy']]);
                    $this->entities[$key] = $entity;
                } else {
                    $this->entities[] = $entity;
                }
            }

            $this->initialized = true;
        }
    }
200528
protected function buildManager()
    {
        $config = new Configuration();

        $this->setUpGeneralConfigurations($config);
        $this->setUpSpecificConfigurations($config);

        $eventManager = $this->getEventManager();
        if ($this->getEventSubscribers() !== null) {
            /* @var array $eventSubscribers */
            $eventSubscribers = $this->getEventSubscribers();

            foreach ($eventSubscribers as $eventSubscriber) {
                $eventManager->addEventSubscriber($eventSubscriber);
            }
        }

        $entityManager = EntityManager::create($this->getOption('connection'), $config, $eventManager);

        $customMappingTypes = $this->getCustomMappingTypes();

        $platform = $entityManager->getConnection()->getDatabasePlatform();
        foreach ($this->getCustomTypes() as $type => $class) {
            if (Type::hasType($type)) {
                Type::overrideType($type, $class);
            } else {
                Type::addType($type, $class);
            }

            $platform->registerDoctrineTypeMapping(
                $type,
                array_key_exists($type, $customMappingTypes) ? $customMappingTypes[$type] : $type
            );
        }

        return $entityManager;
    }
658029
protected function setUp()
	{
		$this->bbcodeMonkey = new BBCodeMonkey($this->configurator);
		$this->collection   = new BBCodeCollection;
		$this->repositories = new RepositoryCollection($this->bbcodeMonkey);
		$this->repositories->add('default', __DIR__ . '/Configurator/repository.xml');
	}
124994
private function setup()
    {
        $this['licenser'] = function () {
            return new Licenser(new Finder());
        };

        $this['command.licenser'] = function ($c) {
            return new LicenserCommand($c['licenser'], $c['license_header_factory']);
        };

        $this['command.check'] = function ($c) {
            return new CheckCommand($c['licenser'], $c['license_header_factory']);
        };

        $this['twig.templating'] = function () {
            $loader = new \Twig_Loader_Filesystem(__DIR__ . '/../../licenses');
            return new \Twig_Environment($loader);
        };

        $this['license_header_factory'] = function ($c) {
            return new LicenseHeaderFactory($c['twig.templating']);
        };
    }
375202
public function setup()
    {
        $this->reader('request.key', function (Subject $subject, $key = null) {
            $request = $this->_request();

            return $request->getParam($key, null);
        });

        $this->reader('request.data', function (Subject $subject, $key = null) {
            $request = $this->_request();

            return $request->getData($key);
        });

        $this->reader('request.query', function (Subject $subject, $key = null) {
            $request = $this->_request();

            return $request->getQuery($key);
        });

        $this->reader('entity.field', function (Subject $subject, $key = null) {
            return $subject->entity->get($key);
        });

        $this->reader('subject.key', function (Subject $subject, $key = null) {
            if (!isset($subject->{$key})) {
                return null;
            }

            return $subject->{$key};
        });
    }
1065385
private function setUp()
    {
        // Load the fonts for the drag hint (see #4838)
        $GLOBALS['TL_CONFIG']['loadGoogleFonts'] = true;

        $this->rootDir = \dirname(System::getContainer()->getParameter('kernel.root_dir'));

        if (!$this->dataContainer || !$this->orderField) {
            return;
        }

        $value = $this->dataContainer->getModel()->getProperty($this->orderField);

        // support serialized values.
        if (!\is_array($value)) {
            $value = StringUtil::deserialize($value, true);
        }

        $this->orderId         = $this->orderField . \str_replace($this->strField, '', $this->strId);
        $this->orderFieldValue = (!empty($value) && \is_array($value)) ? \array_filter($value) : [];
    }
312062
private function getOrmEntityManagersNode()
    {
        $treeBuilder = new TreeBuilder('entity_managers');

        if (method_exists($treeBuilder, 'getRootNode')) {
            $node = $treeBuilder->getRootNode();
        } else {
            // BC layer for symfony/config 4.1 and older
            $node = $treeBuilder->root('entity_managers');
        }

        $node
            ->requiresAtLeastOneElement()
            ->useAttributeAsKey('name')
            ->prototype('array')
                ->addDefaultsIfNotSet()
                ->append($this->getOrmCacheDriverNode('query_cache_driver'))
                ->append($this->getOrmCacheDriverNode('metadata_cache_driver'))
                ->append($this->getOrmCacheDriverNode('result_cache_driver'))
                ->append($this->getOrmEntityListenersNode())
                ->children()
                    ->scalarNode('connection')->end()
                    ->scalarNode('class_metadata_factory_name')->defaultValue('Doctrine\ORM\Mapping\ClassMetadataFactory')->end()
                    ->scalarNode('default_repository_class')->defaultValue('Doctrine\ORM\EntityRepository')->end()
                    ->scalarNode('auto_mapping')->defaultFalse()->end()
                    ->scalarNode('naming_strategy')->defaultValue('doctrine.orm.naming_strategy.default')->end()
                    ->scalarNode('quote_strategy')->defaultValue('doctrine.orm.quote_strategy.default')->end()
                    ->scalarNode('entity_listener_resolver')->defaultNull()->end()
                    ->scalarNode('repository_factory')->defaultValue('doctrine.orm.container_repository_factory')->end()
                ->end()
                ->children()
                    ->arrayNode('second_level_cache')
                        ->children()
                            ->append($this->getOrmCacheDriverNode('region_cache_driver'))
                            ->scalarNode('region_lock_lifetime')->defaultValue(60)->end()
                            ->booleanNode('log_enabled')->defaultValue($this->debug)->end()
                            ->scalarNode('region_lifetime')->defaultValue(0)->end()
                            ->booleanNode('enabled')->defaultValue(true)->end()
                            ->scalarNode('factory')->end()
                        ->end()
                        ->fixXmlConfig('region')
                        ->children()
                            ->arrayNode('regions')
                                ->useAttributeAsKey('name')
                                ->prototype('array')
                                    ->children()
                                        ->append($this->getOrmCacheDriverNode('cache_driver'))
                                        ->scalarNode('lock_path')->defaultValue('%kernel.cache_dir%/doctrine/orm/slc/filelock')->end()
                                        ->scalarNode('lock_lifetime')->defaultValue(60)->end()
                                        ->scalarNode('type')->defaultValue('default')->end()
                                        ->scalarNode('lifetime')->defaultValue(0)->end()
                                        ->scalarNode('service')->end()
                                        ->scalarNode('name')->end()
                                    ->end()
                                ->end()
                            ->end()
                        ->end()
                        ->fixXmlConfig('logger')
                        ->children()
                            ->arrayNode('loggers')
                                ->useAttributeAsKey('name')
                                ->prototype('array')
                                    ->children()
                                        ->scalarNode('name')->end()
                                        ->scalarNode('service')->end()
                                    ->end()
                                ->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
                ->fixXmlConfig('hydrator')
                ->children()
                    ->arrayNode('hydrators')
                        ->useAttributeAsKey('name')
                        ->prototype('scalar')->end()
                    ->end()
                ->end()
                ->fixXmlConfig('mapping')
                ->children()
                    ->arrayNode('mappings')
                        ->useAttributeAsKey('name')
                        ->prototype('array')
                            ->beforeNormalization()
                                ->ifString()
                                ->then(static function ($v) {
                                    return ['type' => $v];
                                })
                            ->end()
                            ->treatNullLike([])
                            ->treatFalseLike(['mapping' => false])
                            ->performNoDeepMerging()
                            ->children()
                                ->scalarNode('mapping')->defaultValue(true)->end()
                                ->scalarNode('type')->end()
                                ->scalarNode('dir')->end()
                                ->scalarNode('alias')->end()
                                ->scalarNode('prefix')->end()
                                ->booleanNode('is_bundle')->end()
                            ->end()
                        ->end()
                    ->end()
                    ->arrayNode('dql')
                        ->fixXmlConfig('string_function')
                        ->fixXmlConfig('numeric_function')
                        ->fixXmlConfig('datetime_function')
                        ->children()
                            ->arrayNode('string_functions')
                                ->useAttributeAsKey('name')
                                ->prototype('scalar')->end()
                            ->end()
                            ->arrayNode('numeric_functions')
                                ->useAttributeAsKey('name')
                                ->prototype('scalar')->end()
                            ->end()
                            ->arrayNode('datetime_functions')
                                ->useAttributeAsKey('name')
                                ->prototype('scalar')->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
                ->fixXmlConfig('filter')
                ->children()
                    ->arrayNode('filters')
                        ->info('Register SQL Filters in the entity manager')
                        ->useAttributeAsKey('name')
                        ->prototype('array')
                            ->beforeNormalization()
                                ->ifString()
                                ->then(static function ($v) {
                                    return ['class' => $v];
                                })
                            ->end()
                            ->beforeNormalization()
                                // The content of the XML node is returned as the "value" key so we need to rename it
                                ->ifTrue(static function ($v) {
                                    return is_array($v) && isset($v['value']);
                                })
                                ->then(static function ($v) {
                                    $v['class'] = $v['value'];
                                    unset($v['value']);

                                    return $v;
                                })
                            ->end()
                            ->fixXmlConfig('parameter')
                            ->children()
                                ->scalarNode('class')->isRequired()->end()
                                ->booleanNode('enabled')->defaultFalse()->end()
                                ->arrayNode('parameters')
                                    ->useAttributeAsKey('name')
                                    ->prototype('variable')->end()
                                ->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end();

        return $node;
    }
1354237
public function setup()
    {
        $app = $this->getApplication();

        $options = $app->config('doctrine');
        if (is_array($options)) {
            $this->setOptions($this->options, $options);
        }

        $proxyDir = $this->getOption('proxy_path');
        $cache = DoctrineCacheFactory::configureCache($this->getOption('cache_driver'));

        $config = Setup::createConfiguration(!!$app->config('debug'), $proxyDir, $cache);
        $config->setNamingStrategy(new UnderscoreNamingStrategy());

        $this->setupAnnotationMetadata();

        if (!$this->setupMetadataDriver($config)) {
            throw new \RuntimeException('No Metadata Driver defined');
        }
        $config->setAutoGenerateProxyClasses($this->getOption('auto_generate_proxies', true) == true);

        $connection = $this->getOption('connection');

        $app->container->singleton(
            'entityManager',
            function () use ($connection, $config) {
                return EntityManager::create($connection, $config);
            }
        );
    }
223570
public function initializeManager()
    {
        $handlers = $this->handlerObjectBackend->loadObject();
        if (!is_array($handlers)) {
            $handlers = array();
        }
        
        $this->handlers = $handlers;
    }
1016337
public function init()
    {
        $this->setName('data')
             ->setLabel('Group data')
             ->setUseAsBaseFieldset(true)
             ->setHydrator(new EntityHydrator());
        
        $this->add(
            array(
            'type' => 'Hidden',
            'name' => 'id',
            )
        );
        
        $this->add(
            array(
            'type' => 'Text',
            'name' => 'name',
            'options' => array(
                'label' => /*@translate*/ 'Group name',
                'description' => /* @translate */ 'Select a group name. You can add users to your group and then work together on jobs and job applications.',
                    
            ),
            )
        );
        
        $this->add(
            array(
            'type' => 'Auth/Group/Users',
            )
        );
    }