当前位置: 首页>>代码示例>>PHP>>正文


PHP DI\ContainerBuilder类代码示例

本文整理汇总了PHP中Nette\DI\ContainerBuilder的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder类的具体用法?PHP ContainerBuilder怎么用?PHP ContainerBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ContainerBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setupTemplating

 /**
  * @param \Nette\DI\ContainerBuilder $container
  * @param array $config
  */
 private function setupTemplating(ContainerBuilder $container, array $config)
 {
     $def = $container->addDefinition($this->prefix('templateFilesFormatter'))->setClass('Lohini\\Templating\\TemplateFilesFormatter')->addSetup('$skin', [$config['skin']]);
     foreach ($config['dirs'] as $dir => $priority) {
         $def->addSetup('addDir', Validators::isNumericInt($dir) ? [$priority] : [$container->expand($dir), $priority]);
     }
 }
开发者ID:lohini,项目名称:framework,代码行数:11,代码来源:LohiniExtension.php

示例2: addWebLoader

 private function addWebLoader(\Nette\DI\ContainerBuilder $builder, $name, $config)
 {
     $filesServiceName = $this->prefix($name . 'Files');
     $files = $builder->addDefinition($filesServiceName)->setClass('WebLoader\\FileCollection')->setArguments(array($config['sourceDir']));
     foreach ($config['files'] as $file) {
         // finder support
         if (is_array($file) && isset($file['files']) && (isset($file['in']) || isset($file['from']))) {
             $finder = \Nette\Utils\Finder::findFiles($file['files']);
             unset($file['files']);
             foreach ($file as $method => $params) {
                 call_user_func_array(array($finder, $method), array($params));
             }
             foreach ($finder as $foundFile) {
                 $files->addSetup('addFile', array((string) $foundFile));
             }
         } else {
             $files->addSetup('addFile', array($file));
         }
     }
     $files->addSetup('addRemoteFiles', array($config['remoteFiles']));
     $compiler = $builder->addDefinition($this->prefix($name . 'Compiler'))->setClass('WebLoader\\Compiler')->setArguments(array('@' . $filesServiceName, $config['namingConvention'], $config['tempDir']));
     $compiler->addSetup('setJoinFiles', array($config['joinFiles']));
     foreach ($config['filters'] as $filter) {
         $compiler->addSetup('addFilter', array($filter));
     }
     foreach ($config['fileFilters'] as $filter) {
         $compiler->addSetup('addFileFilter', array($filter));
     }
     // todo css media
 }
开发者ID:norbe,项目名称:WebLoader,代码行数:30,代码来源:Extension.php

示例3: addWebLoader

 private function addWebLoader(ContainerBuilder $builder, $name, $config)
 {
     $filesServiceName = $this->prefix($name . 'Files');
     $files = $builder->addDefinition($filesServiceName)->setClass('WebLoader\\FileCollection')->setArguments(array($config['sourceDir']));
     foreach ($this->findFiles($config['files'], $config['sourceDir']) as $file) {
         $files->addSetup('addFile', array($file));
     }
     foreach ($this->findFiles($config['watchFiles'], $config['sourceDir']) as $file) {
         $files->addSetup('addWatchFile', array($file));
     }
     $files->addSetup('addRemoteFiles', array($config['remoteFiles']));
     $compiler = $builder->addDefinition($this->prefix($name . 'Compiler'))->setClass('WebLoader\\Compiler')->setArguments(array('@' . $filesServiceName, $config['namingConvention'], $config['tempDir']));
     $compiler->addSetup('setJoinFiles', array($config['joinFiles']));
     if ($builder->parameters['webloader']['debugger']) {
         $compiler->addSetup('@' . $this->prefix('tracyPanel') . '::addLoader', array($name, '@' . $this->prefix($name . 'Compiler')));
     }
     foreach ($config['filters'] as $filter) {
         $compiler->addSetup('addFilter', array($filter));
     }
     foreach ($config['fileFilters'] as $filter) {
         $compiler->addSetup('addFileFilter', array($filter));
     }
     if (isset($config['debug']) && $config['debug']) {
         $compiler->addSetup('enableDebugging');
     }
     $compiler->addSetup('setCheckLastModified', array($config['checkLastModified']));
     // todo css media
 }
开发者ID:janmarek,项目名称:webloader,代码行数:28,代码来源:Extension.php

示例4: createRepositoryService

 protected function createRepositoryService($repositoryData, ContainerBuilder $builder, $mapperName)
 {
     $repositoryName = $this->prefix('repositories.' . $repositoryData['name']);
     if (!$builder->hasDefinition($repositoryName)) {
         $builder->addDefinition($repositoryName)->setClass($repositoryData['class'])->setArguments(['@' . $mapperName, '@' . $this->prefix('dependencyProvider')])->addSetup('onModelAttach', ['@' . $this->prefix('model')]);
     }
 }
开发者ID:Zarganwar,项目名称:orm,代码行数:7,代码来源:OrmExtension.php

示例5: setupCompileTemplatesCommand

 private function setupCompileTemplatesCommand(ContainerBuilder $builder, array $config)
 {
     $config = $this->validateConfig($this->compileTemplatesDefaults, $config, 'compileTemplates');
     Validators::assertField($config, 'source', 'string|array');
     $builder->addDefinition($this->prefix('compileTemplates'))->setClass(CompileTemplatesCommand::class, [array_map(function ($directory) use($builder) {
         Validators::assert($directory, 'string');
         return Helpers::expand($directory, $builder->parameters);
     }, (array) $config['source'])])->addTag(ConsoleExtension::TAG_COMMAND)->setAutowired(false);
 }
开发者ID:lookyman,项目名称:commands,代码行数:9,代码来源:CommandsExtension.php

示例6: getSortedConfigurators

 /**
  * @param ContainerBuilder $builder
  * @return array
  */
 private function getSortedConfigurators(ContainerBuilder $builder)
 {
     $configurators = $builder->findByTag(self::TAG_CONFIGURATOR);
     uasort($configurators, function ($a, $b) {
         $a = is_numeric($a) ? (double) $a : 0;
         $b = is_numeric($b) ? (double) $b : 0;
         return $a < $b ? -1 : ($a > $b ? 1 : 0);
     });
     return $configurators;
 }
开发者ID:lookyman,项目名称:nette-texy,代码行数:14,代码来源:TexyExtension.php

示例7: configMapper

 /**
  * Adds mapper service into container
  * @return ServiceDefinition
  */
 protected function configMapper(ContainerBuilder $builder, array $config)
 {
     if ($config['defaultEntityNamespace'] !== NULL && !is_string($config['defaultEntityNamespace'])) {
         throw new \RuntimeException('DefaultEntityNamespace must be NULL or string, ' . gettype($config['defaultEntityNamespace']) . ' given');
     }
     $mapper = $builder->addDefinition($this->prefix('mapper'))->setClass($config['mapper'], array($config['defaultEntityNamespace']));
     $this->processEntityProviders($mapper, $config);
     $this->processUserEntities($mapper, $config);
     return $mapper;
 }
开发者ID:janpecha,项目名称:leanmapper-extension,代码行数:14,代码来源:LeanMapperExtension.php

示例8: getByType

 /**
  * @param ContainerBuilder $container
  * @param string $type
  * @return ServiceDefinition|null
  */
 private function getByType(ContainerBuilder $container, $type)
 {
     $definitionas = $container->getDefinitions();
     foreach ($definitionas as $definition) {
         if ($definition->class === $type) {
             return $definition;
         }
     }
     return NULL;
 }
开发者ID:drahak,项目名称:oauth2,代码行数:15,代码来源:Extension.php

示例9: install

 public function install(Nette\DI\ContainerBuilder $builder)
 {
     foreach ($this->listener as $class_name => $on) {
         $definition = $builder->getDefinition("annevents." . $class_name);
         foreach ($on as $on_name => $data) {
             foreach ($data['call'] as $add) {
                 $definition->addSetup('$service->' . $on_name . '[]=?->' . $add['method'], array($builder->getDefinition('annevents.' . str_replace('\\', '_', $add['class']))));
             }
         }
     }
 }
开发者ID:dipcom,项目名称:annevents,代码行数:11,代码来源:Guideline.php

示例10: createSubscribersMap

 private function createSubscribersMap(\Nette\DI\ContainerBuilder $builder)
 {
     $map = [];
     foreach ($builder->findByTag(self::TAG_SUBSCRIBER) as $serviceName => $tagProperties) {
         $def = $builder->getDefinition($serviceName);
         $class = $def->getClass();
         $events = $class::getSubscribedEvents();
         foreach ($events as $eventName => $callbacks) {
             foreach ($callbacks as $function) {
                 $map[$eventName][] = [$serviceName, $function];
             }
         }
     }
     return $map;
 }
开发者ID:bazo,项目名称:nette-events-extension,代码行数:15,代码来源:EventsExtension.php

示例11: findRoutes

 /**
  * @param  Nette\DI\ContainerBuilder $builder
  * @return array
  */
 private function findRoutes(Nette\DI\ContainerBuilder $builder)
 {
     /**
      * Find all presenters and their routes
      */
     $presenters = $builder->findByTag('nette.presenter');
     $routes = [];
     foreach ($presenters as $presenter) {
         $this->findRoutesInPresenter($presenter, $routes);
     }
     /**
      * Return routes sorted by priority
      */
     return $this->sortByPriority($routes);
 }
开发者ID:ublaboo,项目名称:api-router,代码行数:19,代码来源:ApiRouterExtension.php

示例12: processAuthenticators

 /**
  * @param ContainerBuilder $container
  * @param array $config
  */
 private function processAuthenticators(ContainerBuilder $container, array $config)
 {
     $authentication = $container->addDefinition($this->prefix('authentication'))->setClass('Flame\\Rest\\Security\\Authentication');
     if (!$container->parameters['debugMode'] && count($config['ips'])) {
         $ipAuthenticator = $container->addDefinition($this->prefix('ipAuthenticator'))->setClass('Flame\\Rest\\Security\\Authenticators\\IpAuthenticator')->setArguments(array($config['ips']));
         $authentication->addSetup('addAuthenticator', array($ipAuthenticator));
     }
     if (!$container->parameters['debugMode'] && count($config['referers'])) {
         $refererAuthenticator = $container->addDefinition($this->prefix('refererAuthenticator'))->setClass('Flame\\Rest\\Security\\Authenticators\\RefererAuthenticator')->setArguments(array($config['referers']));
         $authentication->addSetup('addAuthenticator', array($refererAuthenticator));
     }
     foreach ($config['authenticators'] as $k => $authenticatorConfig) {
         $authenticator = $container->addDefinition($this->prefix('authenticator' . $k))->setClass($authenticatorConfig);
         $authentication->addSetup('addAuthenticator', array($authenticator));
     }
 }
开发者ID:Budry,项目名称:TinyREST,代码行数:20,代码来源:RestExtension.php

示例13: prepareNetteDatabase

 private function prepareNetteDatabase(\Nette\DI\ContainerBuilder $builder)
 {
     $ndbConnectionSectionKeys = ['dsn' => NULL, 'user' => NULL, 'password' => NULL];
     /** @var \Nette\DI\CompilerExtension $extension */
     foreach ($this->compiler->getExtensions('Nette\\Bridges\\DatabaseDI\\DatabaseExtension') as $extension) {
         if (array_intersect_key($extension->config, $ndbConnectionSectionKeys)) {
             $extensionConfig = $extension->config;
             $definitionName = $extension->name . '.default.connection';
             $builder->getDefinition($definitionName)->setClass('Testbench\\Mocks\\NetteDatabaseConnectionMock', [$extensionConfig['dsn'], $extensionConfig['user'], $extensionConfig['password'], isset($extensionConfig['options']) ? $extensionConfig['options'] + ['lazy' => TRUE] : []]);
         } else {
             foreach ($extension->config as $sectionName => $sectionConfig) {
                 $definitionName = $extension->name . '.' . $sectionName . '.connection';
                 $builder->getDefinition($definitionName)->setClass('Testbench\\Mocks\\NetteDatabaseConnectionMock', [$sectionConfig['dsn'], $sectionConfig['user'], $sectionConfig['password'], isset($sectionConfig['options']) ? $sectionConfig['options'] + ['lazy' => TRUE] : []]);
             }
         }
     }
 }
开发者ID:mrtnzlml,项目名称:testbench,代码行数:17,代码来源:TestbenchExtension.php

示例14: loadRoutes

 /**
  * Routes definition
  *
  * @param ContainerBuilder $container Container
  * @param array            $config    Config
  *
  * @return void
  */
 protected function loadRoutes(ContainerBuilder $container, $config)
 {
     $container->addDefinition($this->prefix('storages'))->setClass('MouseOver\\Storage\\Application\\StorageList');
     $container->addDefinition($this->prefix('responder'))->setClass('MouseOver\\Storage\\Application\\StorageResponder');
     $container->addDefinition($this->prefix('linkResolver'))->setClass('MouseOver\\Storage\\Application\\StorageLinkResolver', [$config['module']]);
     $container->getDefinition('nette.latte')->addSetup('MouseOver\\Storage\\Application\\StorageMacros::install($service->getCompiler(), ?)', array($this->prefix('@linkResolver')));
     $routesList = $container->addDefinition($this->prefix('storageRoutes'))->setClass('Nette\\Application\\Routers\\RouteList')->setAutowired(false);
     $routesList->addSetup('$service[] = new Nette\\Application\\Routers\\Route(?, function ($presenter, $storage, $file) { return ?->handle($storage, $file, $presenter->request->getParameters()); })', array($config['module'] . '/<storage>/<file [a-zA-Z0-9\\-_.\\/]+>', $this->prefix('@responder')));
     $container->getDefinition('router')->addSetup('MouseOver\\Storage\\DI\\StorageExtension::prependTo($service, ?)', [$this->prefix('@storageRoutes')]);
 }
开发者ID:mouse-over,项目名称:storage,代码行数:18,代码来源:StorageExtension.php

示例15: processPackages

 /**
  * @param ContainerBuilder $builder
  * @throws \movi\InvalidArgumentException
  */
 private function processPackages(ContainerBuilder $builder)
 {
     $manager = $builder->getDefinition($this->prefix('manager'));
     $packages = $builder->parameters['packages'];
     if (count($packages) > 0) {
         foreach (array_values($packages) as $data) {
             $class = $this->getPackageClass($data);
             if (class_exists($class)) {
                 $package = new $class($data);
                 if (!$package instanceof Package) {
                     throw new InvalidArgumentException("Package class must be an instance of movi\\Packages\\Package.");
                 }
             } else {
                 $package = new Package($data);
             }
             // Compile the package
             $package->onCompile($this->compiler);
             $this->processExtensions($package->extensions);
             $manager->addSetup('addPackage', [$package]);
         }
     }
 }
开发者ID:peterzadori,项目名称:movi,代码行数:26,代码来源:PackagesExtension.php


注:本文中的Nette\DI\ContainerBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。