• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP DI\ContainerBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: setupDatabase

 private function setupDatabase(ContainerBuilder $container, array $config)
 {
     if (isset($config['dsn'])) {
         $config = array('default' => $config);
     }
     $autowired = true;
     foreach ((array) $config as $name => $info) {
         if (!is_array($info)) {
             continue;
         }
         $this->validate($info, $this->databaseDefaults, 'flunorette');
         $info += array('autowired' => $autowired) + $this->databaseDefaults;
         $autowired = false;
         foreach (array('transactionCounter', 'delimiteMode', 'lazy', 'driverClass') as $option) {
             if (isset($info[$option])) {
                 $info['options'][$option] = $info[$option];
             }
         }
         foreach ((array) $info['options'] as $key => $value) {
             if (preg_match('#^PDO::\\w+\\z#', $key)) {
                 unset($info['options'][$key]);
                 $info['options'][constant($key)] = $value;
             }
         }
         if (!$info['reflection']) {
             $reflection = null;
         } elseif (is_string($info['reflection'])) {
             $reflection = new Statement(preg_match('#^[a-z]+\\z#', $info['reflection']) ? 'Flunorette\\Reflections\\' . ucfirst($info['reflection']) . 'Reflection' : $info['reflection'], strtolower($info['reflection']) === 'discovered' ? array('@self') : array());
         } else {
             $tmp = Compiler::filterArguments(array($info['reflection']));
             $reflection = reset($tmp);
         }
         $connection = $container->addDefinition($this->prefix($name))->setClass('Flunorette\\Connection', array($info['dsn'], $info['user'], $info['password'], $info['options']))->setAutowired($info['autowired'])->addSetup('setCacheStorage')->addSetup('Nette\\Diagnostics\\Debugger::getBlueScreen()->addPanel(?)', array('Flunorette\\Bridges\\Nette\\Diagnostics\\ConnectionPanel::renderException'));
         if ($container->parameters['debugMode'] && $info['debugger']) {
             $connection->addSetup('Flunorette\\Helpers::createDebugPanel', array($connection, !empty($info['explain']), $name));
         }
     }
 }
开发者ID:icaine,项目名称:flunorette,代码行数:38,代码来源:FlunoretteExtension.php


示例17: parseServices

 /**
  * Parses section 'services' from configuration file.
  * @return void
  */
 public static function parseServices(Nette\DI\ContainerBuilder $container, array $config, $namespace = NULL)
 {
     $services = isset($config['services']) ? $config['services'] : array();
     $factories = isset($config['factories']) ? $config['factories'] : array();
     $all = array_merge($services, $factories);
     uasort($all, function ($a, $b) {
         return strcmp(Helpers::isInheriting($a), Helpers::isInheriting($b));
     });
     foreach ($all as $origName => $def) {
         $shared = array_key_exists($origName, $services);
         if ((string) (int) $origName === (string) $origName) {
             $name = (string) (count($container->getDefinitions()) + 1);
         } elseif ($shared && array_key_exists($origName, $factories)) {
             throw new Nette\DI\ServiceCreationException("It is not allowed to use services and factories with the same name: '{$origName}'.");
         } else {
             $name = ($namespace ? $namespace . '.' : '') . strtr($origName, '\\', '_');
         }
         if (($parent = Helpers::takeParent($def)) && $parent !== $name) {
             $container->removeDefinition($name);
             $definition = $container->addDefinition($name);
             if ($parent !== Helpers::OVERWRITE) {
                 foreach ($container->getDefinition($parent) as $k => $v) {
                     $definition->{$k} = unserialize(serialize($v));
                     // deep clone
                 }
             }
         } elseif ($container->hasDefinition($name)) {
             $definition = $container->getDefinition($name);
             if ($definition->shared !== $shared) {
                 throw new Nette\DI\ServiceCreationException("It is not allowed to use service and factory with the same name '{$name}'.");
             }
         } else {
             $definition = $container->addDefinition($name);
         }
         try {
             static::parseService($definition, $def, $shared);
         } catch (\Exception $e) {
             throw new Nette\DI\ServiceCreationException("Service '{$name}': " . $e->getMessage(), NULL, $e);
         }
     }
 }
开发者ID:genextwebs,项目名称:dropbox-sample,代码行数:45,代码来源:Compiler.php


示例18: setupSecurity

 public function setupSecurity(ContainerBuilder $container)
 {
     $container->addDefinition($this->prefix('defaultPresenter'))->setClass('Venne\\Security\\AdminModule\\DefaultPresenter')->addTag(SystemExtension::TAG_ADMINISTRATION, array('link' => 'Admin:Security:Default:', 'category' => 'System', 'name' => 'Security', 'description' => 'Manage users, roles and permissions', 'priority' => 60));
     $container->addDefinition($this->prefix('accountPresenter'))->setClass('Venne\\Security\\AdminModule\\AccountPresenter');
 }
开发者ID:venne,项目名称:venne,代码行数:5,代码来源:SecurityExtension.php


示例19: setupSystem

 public function setupSystem(ContainerBuilder $container, array $config)
 {
     $container->addDefinition($this->prefix('formRenderer'))->setClass('Venne\\System\\Forms\\Bootstrap3Renderer');
     $container->addDefinition($this->prefix('admin.basicFormFactory'))->setClass('Nette\\Application\\UI\\Form')->setArguments(array(null, null))->setImplement('Venne\\Forms\\IFormFactory')->addSetup('setRenderer', array(new Statement($this->prefix('@formRenderer'))))->addSetup('setTranslator', array(new Statement('@Nette\\Localization\\ITranslator')))->setAutowired(false);
     $container->addDefinition($this->prefix('admin.ajaxFormFactory'))->setClass('Nette\\Application\\UI\\Form')->setArguments(array(null, null))->setImplement('Venne\\Forms\\IFormFactory')->addSetup('setRenderer', array(new Statement($this->prefix('@formRenderer'))))->addSetup('setTranslator', array(new Statement('@Nette\\Localization\\ITranslator')))->addSetup('$service->getElementPrototype()->class[] = ?', array('ajax'))->setAutowired(false);
     $container->addDefinition($this->prefix('admin.configFormFactory'))->setClass('Venne\\System\\UI\\ConfigFormFactory', array(new PhpLiteral('$configFile'), new PhpLiteral('$section')))->addSetup('setFormFactory', array(new Statement('@system.admin.basicFormFactory')))->setAutowired(false)->setParameters(array('configFile', 'section'));
     $container->addDefinition($this->prefix('registrationControlFactory'))->setClass('Venne\\Security\\Registration\\RegistrationControl', array(new PhpLiteral('$invitations'), new PhpLiteral('$userType'), new PhpLiteral('$mode'), new PhpLiteral('$loginProviderMode'), new PhpLiteral('$roles')))->setImplement('Venne\\Security\\Registration\\IRegistrationControlFactory')->setInject(true);
     $container->addDefinition($this->prefix('system.loginFormFactory'))->setClass('Venne\\System\\AdminModule\\LoginFormFactory', array(new Statement('@system.admin.basicFormFactory')));
     $container->addDefinition($this->prefix('system.dashboardPresenter'))->setClass('Venne\\System\\AdminModule\\DashboardPresenter');
     $container->addDefinition($this->prefix('cssControlFactory'))->setClass('Venne\\System\\Components\\CssControl')->setImplement('Venne\\System\\Components\\CssControlFactory')->setArguments(array(null))->setInject(true);
     $container->addDefinition($this->prefix('jsControlFactory'))->setClass('Venne\\System\\Components\\JsControl')->setImplement('Venne\\System\\Components\\JsControlFactory')->setArguments(array(null))->setInject(true);
     $container->addDefinition($this->prefix('navbarControlFactory'))->setImplement('Venne\\System\\Components\\INavbarControlFactory')->setArguments(array(null))->setInject(true);
     $container->addDefinition($this->prefix('loginControlFactory'))->setImplement('Venne\\Security\\Login\\ILoginControlFactory')->setInject(true);
     $container->addDefinition($this->prefix('gridoFactory'))->setImplement('Venne\\System\\Components\\IGridoFactory')->setArguments(array(null, null))->setInject(true);
     $container->addDefinition($this->prefix('gridControlFactory'))->setImplement('Venne\\System\\Components\\AdminGrid\\IAdminGridFactory')->setArguments(array(new PhpLiteral('$repository')))->setParameters(array('repository'))->setInject(true);
     $container->addDefinition($this->prefix('flashMessageControlFactory'))->setImplement('Venne\\System\\Components\\IFlashMessageControlFactory')->setArguments(array(null))->setInject(true)->addTag(WidgetsExtension::TAG_WIDGET, 'flashMessage');
 }
开发者ID:venne,项目名称:venne,代码行数:17,代码来源:SystemExtension.php


示例20: parseServices

 /**
  * Parses section 'services' from (unexpanded) configuration file.
  * @return void
  */
 public static function parseServices(ContainerBuilder $builder, array $config, string $namespace = NULL)
 {
     $services = isset($config['services']) ? $config['services'] : [];
     $depths = [];
     foreach ($services as $name => $def) {
         $path = [];
         while (Config\Helpers::isInheriting($def)) {
             $path[] = $def;
             $def = isset($services[$def[Config\Helpers::EXTENDS_KEY]]) ? $services[$def[Config\Helpers::EXTENDS_KEY]] : [];
             if (in_array($def, $path, TRUE)) {
                 throw new ServiceCreationException("Circular reference detected for service '{$name}'.");
             }
         }
         $depths[$name] = count($path);
     }
     array_multisort($depths, $services);
     foreach ($services as $name => $def) {
         if ((string) (int) $name === (string) $name) {
             $postfix = $def instanceof Statement && is_string($def->getEntity()) ? '.' . $def->getEntity() : (is_scalar($def) ? ".{$def}" : '');
             $name = count($builder->getDefinitions()) + 1 . preg_replace('#\\W+#', '_', $postfix);
         } elseif ($namespace) {
             $name = $namespace . '.' . $name;
         }
         $params = $builder->parameters;
         if (is_array($def) && isset($def['parameters'])) {
             foreach ((array) $def['parameters'] as $k => $v) {
                 $v = explode(' ', is_int($k) ? $v : $k);
                 $params[end($v)] = $builder::literal('$' . end($v));
             }
         }
         $def = Helpers::expand($def, $params);
         if (($parent = Config\Helpers::takeParent($def)) && $parent !== $name) {
             $builder->removeDefinition($name);
             $definition = $builder->addDefinition($name, $parent === Config\Helpers::OVERWRITE ? NULL : unserialize(serialize($builder->getDefinition($parent))));
         } elseif ($builder->hasDefinition($name)) {
             $definition = $builder->getDefinition($name);
         } else {
             $definition = $builder->addDefinition($name);
         }
         try {
             static::parseService($definition, $def);
         } catch (\Exception $e) {
             throw new ServiceCreationException("Service '{$name}': " . $e->getMessage(), 0, $e);
         }
     }
 }
开发者ID:kukulich,项目名称:di,代码行数:50,代码来源:Compiler.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP DI\Helpers类代码示例发布时间:2022-05-23
下一篇:
PHP DI\Container类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap