create a new container instance

@param ProviderRepository|null $providerRepository
@throws ProviderException
@return Container
15723
public static function create(ProviderRepository $providerRepository = null)
    {
        $container = new Container(
            $providerRepository
        );


        if (!$container->isProvided(AnnotationServiceProvider::class)) {
            $container->addProvider(AnnotationServiceProvider::class);
        }

        $container->add(
            Container::class,
            function () use ($container) {
                return $container;
            }
        )->alias(ContainerInterface::class);

        return $container;
    }
182117
public static function create()
    {
        $request = self::makeRequest();
        $response = self::makeResponse();

        return self::buildProvidersContainer($request, $response);
    }
503702
private function createDataProviderClass(
        string $providerName,
        array $providerData,
        PhpNamespace $namespace
    ): ClassType {
        $dataProvider = $this->createNewDataProvider($providerName, $namespace);
        $providerElements = $providerData['elements'];

        foreach ($providerElements as $element) {
            $this->addProperty($dataProvider, $element);
            $this->addGetter($dataProvider, $element, $providerData['configs']);
            $this->addSetter($dataProvider, $element, $providerData['configs']);
            $this->addUnsetter($dataProvider, $element, $providerData['configs']);
            $this->addHas($dataProvider, $element, $providerData['configs']);
            $this->addSingleSetter($element, $dataProvider, $providerData['configs']);

        }

        $this->addElementsGetter($dataProvider, $providerElements);
        return $dataProvider;
    }
115481
public function registerProvider(Provider $provider)
    {
        $provider->register($this);
        
        $this->container->addProvider($provider);
        
        return $this;
    }
635341
public void createRepository(RepositoryEntry rEntry) throws RepositoryConfigurationException, RepositoryException
   {
      // Need privileges to manage repository.
      SecurityManager security = System.getSecurityManager();
      if (security != null)
      {
         security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
      }

      if (repositoryContainers.containsKey(rEntry.getName()))
      {
         throw new RepositoryConfigurationException("Repository container " + rEntry.getName() + " already started");
      }

      final RepositoryContainer repositoryContainer =
         new RepositoryContainer(parentContainer, rEntry, addNamespacesPlugins);

      // Storing and starting the repository container under
      // key=repository_name
      try
      {
         if (repositoryContainers.putIfAbsent(rEntry.getName(), repositoryContainer) == null)
         {
            SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
            {
               public Void run()
               {
                  repositoryContainer.start();
                  return null;
               }
            });
         }
         else
         {
            throw new RepositoryConfigurationException("Repository container " + rEntry.getName() + " already started");
         }
      }
      catch (Throwable t) //NOSONAR
      {
         repositoryContainers.remove(rEntry.getName());

         throw new RepositoryConfigurationException("Repository container " + rEntry.getName() + " was not started.", t);
      }

      if (!config.getRepositoryConfigurations().contains(rEntry))
      {
         config.getRepositoryConfigurations().add(rEntry);
      }

      registerNodeTypes(rEntry.getName());

      // turn on Repository ONLINE
      ManageableRepository mr =
         (ManageableRepository)repositoryContainer.getComponentInstanceOfType(ManageableRepository.class);
      mr.setState(ManageableRepository.ONLINE);
   }
859847
protected function createCacheDriver(string $name): ProviderContract
    {
        $config = $this->config['cache'][$name] ?? [];
        $cache = $this->getCacheRepository($config);

        return $this->createProvider(new Cache($name, $config, $cache));
    }
444153
public function build(ContainerInterface $container): object
    {
        return new Application(
            $container->get(RequestHandlerInterface::class),
            $container->get(EmitterInterface::class)
        );
    }
391677
public function addProvider($providerOrClass)
    {
        // get the provider object
        $prov  = $this->getProviderInstance($providerOrClass);

        // check added or not
        $class = get_class($prov);
        if (isset($this->providers[$class])) {
            throw new LogicException(
                Message::get(
                    Message::EXT_PROVIDER_DUPPED,
                    get_class($prov)
                ),
                Message::EXT_PROVIDER_DUPPED
            );
        } else {
            // add to the pool
            $this->providers[$class] =
                $prov->setContainer($this->getContainer());
        }
    }
1040603
@Override
    public Container create(ContainerDef definition, ServiceLoader loader) {
        Validate.notNull(definition, "Definition must be specified");

        try {
            // TODO: this whole Classloading thing is a HACK and does not work. Need to split out into multiple JVMs for multi container testing
            //         ClassLoader containerClassLoader;
            //         if(definition.getDependencies().size() > 0)
            //         {
            //            final MavenDependencyResolver resolver = DependencyResolvers.use(MavenDependencyResolver.class).artifacts(
            //                  definition.getDependencies().toArray(new String[0]));
            //
            //            URL[] resolvedURLs = MapObject.convert(resolver.resolveAsFiles());
            //
            //            containerClassLoader = new FilteredURLClassLoader(resolvedURLs, "org.jboss.(arquillian|shrinkwrap)..*");
            //         }
            //         else
            //         {
            //            containerClassLoader = LocalContainerRegistry.class.getClassLoader();
            //         }
            //
            return addContainer(
                //before a Container is added to a collection of containers, inject into its injection point
                injector.inject(new ContainerImpl(
                    definition.getContainerName(),
                    loader.onlyOne(DeployableContainer.class),
                    definition)));
        } catch (Exception e) {
            throw new ContainerCreationException("Could not create Container " + definition.getContainerName(), e);
        }
    }
27269
public static function buildContainer(): Container
    {
        if (self::$container !== null) {
            return self::$container;
        }

        $factory = new ContainerBuilder();
        $factory->useAnnotations(true);

        if ((new ContextHelper())->isProduction()) {
            $factory->enableDefinitionCache();

            if (!is_dir(MELIOR_BASE.'/Data/Persistent/Container/Proxies')) {
                mkdir(MELIOR_BASE.'/Data/Persistent/Container/Proxies', 0755, true);
            }

            $factory->enableCompilation(MELIOR_BASE.'/Data/Persistent/Container');
            $factory->writeProxiesToFile(true, MELIOR_BASE.'/Data/Persistent/Container/Proxies');
        }

        $packages = (new PackageService(new PathHelper(), new ComposerParser()))->getApplicationPackages();

        foreach ($packages as $name => $data) {
            $extra = $data->getExtra();

            if (!array_key_exists('melior', $extra)) {
                continue;
            }

            $meliorData = $extra['melior'];

            if (!array_key_exists('containerDefinitions', $meliorData)) {
                continue;
            }

            $definitions = $meliorData['containerDefinitions'];

            if (is_string($definitions)) {
                $definitions = [$definitions];
            } elseif (!is_array($definitions)) {
                continue;
            }

            foreach ($definitions as $definitionFile) {
                $filepath = realpath("$name/$definitionFile");

                if (!is_file($filepath) || !\is_readable($filepath)) {
                    continue;
                }

                $factory->addDefinitions($filepath);
            }
        }

        $container = $factory->build();

        self::$container = $container;

        return $container;
    }
257238
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('BjyAuthorize\Config');

        if (! isset($config['role_providers']['BjyAuthorize\Provider\Role\ObjectRepositoryProvider'])) {
            throw new InvalidArgumentException(
                'Config for "BjyAuthorize\Provider\Role\ObjectRepositoryProvider" not set'
            );
        }

        $providerConfig = $config['role_providers']['BjyAuthorize\Provider\Role\ObjectRepositoryProvider'];

        if (! isset($providerConfig['role_entity_class'])) {
            throw new InvalidArgumentException('role_entity_class not set in the bjyauthorize role_providers config.');
        }

        if (! isset($providerConfig['object_manager'])) {
            throw new InvalidArgumentException('object_manager not set in the bjyauthorize role_providers config.');
        }

        /* @var $objectManager \Doctrine\Common\Persistence\ObjectManager */
        $objectManager = $serviceLocator->get($providerConfig['object_manager']);

        return new ObjectRepositoryProvider($objectManager->getRepository($providerConfig['role_entity_class']));
    }
1137817
public function configureProviderPlugins(ContainerBuilder $container, array $config, string $providerServiceId): array
    {
        $plugins = [];
        foreach ($config['plugins'] as $plugin) {
            if ($plugin['reference']['enabled']) {
                $plugins[] = $plugin['reference']['id'];
            }
        }

        if (isset($config['cache']) || isset($config['cache_lifetime']) || isset($config['cache_precision'])) {
            if (null === $cacheServiceId = $config['cache']) {
                if (!$container->has('app.cache')) {
                    throw new \LogicException('You need to specify a service for cache.');
                }
                $cacheServiceId = 'app.cache';
            }
            $plugins[] = $providerServiceId.'.cache';
            $container->register($providerServiceId.'.cache', CachePlugin::class)
                ->setPublic(false)
                ->setArguments([new Reference($cacheServiceId), (int) $config['cache_lifetime'], $config['cache_precision']]);
        }

        if (isset($config['limit'])) {
            $plugins[] = $providerServiceId.'.limit';
            $container->register($providerServiceId.'.limit', LimitPlugin::class)
                ->setPublic(false)
                ->setArguments([(int) $config['limit']]);
        }

        if (isset($config['locale'])) {
            $plugins[] = $providerServiceId.'.locale';
            $container->register($providerServiceId.'.locale', LocalePlugin::class)
                ->setPublic(false)
                ->setArguments([$config['locale']]);
        }

        if (isset($config['logger'])) {
            $plugins[] = $providerServiceId.'.logger';
            $container->register($providerServiceId.'.logger', LoggerPlugin::class)
                ->setPublic(false)
                ->setArguments([new Reference($config['logger'])]);
        }

        if ($container->has(FakeIpPlugin::class)) {
            $plugins[] = FakeIpPlugin::class;
        }

        if ($container->has(GeocoderDataCollector::class)) {
            $plugins[] = $providerServiceId.'.profiler';
            $container->register($providerServiceId.'.profiler', ProfilingPlugin::class)
                ->setPublic(false)
                ->setArguments([substr($providerServiceId, strlen('bazinga_geocoder.provider.'))])
                ->addTag('bazinga_geocoder.profiling_plugin');
        }

        return array_map(function (string $id) {
            return new Reference($id);
        }, $plugins);
    }
1111800
private function createRepository(EntityManagerInterface $entityManager, $entityName)
    {
        /** @var ClassMetadata $metadata */
        $metadata            = $entityManager->getClassMetadata($entityName);
        $repositoryClassName = $metadata->getCustomRepositoryClassName()
            ?: $entityManager->getConfiguration()->getDefaultRepositoryClassName();

        return new $repositoryClassName($entityManager, $metadata);
    }
387876
private function createAppRepositories(
        ContainerBuilder $container,
        string $name,
        array $repositoryConfiguration
    ) {
        $this->createRepositoryReferenceServiceReference(
            $container,
            $name,
            $repositoryConfiguration,
            '',
            ''
        );

        $this->createClientRetryMap(
            $container,
            $name,
            $repositoryConfiguration
        );

        $this->createClient(
            $container,
            $name,
            $repositoryConfiguration
        );

        $this->createStandardRepository(
            $container,
            $name,
            $repositoryConfiguration,
            '',
            'app',
            InMemoryAppRepository::class,
            DiskAppRepository::class,
            HttpAppRepository::class
        );

        $this->createStandardRepository(
            $container,
            $name,
            $repositoryConfiguration,
            '',
            'user',
            InMemoryUserRepository::class,
            DiskUserRepository::class,
            HttpUserRepository::class
        );
    }
424253
protected function createContainer()
    {
        $this->container = new ContainerModel();
        $this->reflector = new ContainerReflection();

        $this->container->delegate($this->reflector);
    }
297236
public function createRepositoryFactory(ContainerInterface $container)
    {
        if (empty($this->configFile)) {
            $this->configFile = $container->get('ConfigDirectory') . '/config/database.ini';
        }

        $config = parse_ini_file($this->configFile, true);

        $configuration = new Configuration;

        // Add logger
        $logger = new DebugStack;
        $configuration->setSQLLogger($logger);

        $connection = DriverManager::getConnection(
            [
                'url'     => $config['databaseUrl'],
                'charset' => 'utf8',
            ],
            $configuration
        );
        $transactor = new DoctrineTransactor($connection);

        $repositoryFactory = new RepositoryFactory($config, $connection, $transactor);

        if ($container->has('dispatcher')) {
            $repositoryFactory->setDispatcher($container->get('dispatcher'));
        }

        return $repositoryFactory;
    }
727654
public function createContainer()
  {
    # Create the container
    $container = new Container;

    # If we have auto-wire option on ...
    if (($this->options['autowire'] ?? false)) {
      # Add reflection delegate, so auto-wiring is possible
      $container->delegate( new ReflectionContainer );
    }

    \logger()->debug('Created PSR-11 Container (The Leauge Container)');

    return $container;
  }