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


PHP Helpers::expand方法代码示例

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


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

示例1: loadConfiguration

 /**
  * Processes configuration data. Intended to be overridden by descendant.
  *
  * @throws \Exception
  */
 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $values = Nette\DI\Config\Helpers::merge($this->getConfig(), $this->defaults);
     $config = Nette\DI\Helpers::expand($values['paramsSettings'], $builder->parameters);
     unset($values['paramsSettings']);
     $db = NULL;
     if ($config['database'] !== FALSE) {
         $databaseClass = strpos($config['database'], '\\') ? $config['database'] : 'WebChemistry\\Parameters\\Database\\' . $config['database'];
         if (!class_exists($databaseClass)) {
             throw new \Exception("Class '{$databaseClass}' does not exist.");
         }
         $db = $builder->addDefinition($this->prefix('database'))->setClass('WebChemistry\\Parameters\\IDatabase')->setFactory($databaseClass);
         if ($config['database'] === 'Doctrine') {
             $implements = class_implements($config['entity']);
             if (array_search('WebChemistry\\Parameters\\IEntity', $implements) === FALSE) {
                 throw new ConfigurationException("Class '{$config['entity']}' must implements WebChemistry\\Parameters\\IEntity.");
             }
             $db->addSetup('setEntity', [$config['entity']]);
         }
     }
     $builder->addDefinition($this->prefix('provider'))->setClass('WebChemistry\\Parameters\\Provider', [$values, $config['cache'], $db]);
     if ($config['bar'] && class_exists('Tracy\\Debugger')) {
         $builder->addDefinition($this->prefix('bar'))->setClass('WebChemistry\\Parameters\\Bar\\Debug', [(bool) $db]);
     }
 }
开发者ID:webchemistry,项目名称:parameters,代码行数:31,代码来源:ParametersExtension.php

示例2: _getConfig

 private function _getConfig()
 {
     $config = $this->validateConfig($this->defaults, $this->config);
     $config['log_directory'] = Nette\DI\Helpers::expand($config['log_directory'], $this->getContainerBuilder()->parameters);
     $config['mail_images_base_path'] = Nette\DI\Helpers::expand($config['mail_images_base_path'], $this->getContainerBuilder()->parameters);
     return $config;
 }
开发者ID:JakubKontra,项目名称:mailing,代码行数:7,代码来源:MailingExtension.php

示例3: 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

示例4: beforeCompile

 public function beforeCompile()
 {
     $builder = $this->getContainerBuilder();
     $this->validateConfig($this->defaults);
     $config = $this->getConfig($this->defaults);
     foreach ($builder->findByType('Nette\\Mail\\IMailer') as $name => $def) {
         $builder->removeDefinition($name);
     }
     $builder->addDefinition('fileMailer')->setClass(FileMailer::class, [$config])->addSetup('$tempDir', [Helpers::expand($config['tempDir'], $builder->parameters)]);
 }
开发者ID:Ryby,项目名称:Mail,代码行数:10,代码来源:FileMailerExtension.php

示例5: __construct

 /**
  * @param Container $container
  * @param ManagerRegistry $registry
  */
 public function __construct(Container $container, ManagerRegistry $registry)
 {
     parent::__construct('dwarfSearch:import');
     $this->entityManager = $registry->getManager();
     $this->seasonsRepository = $registry->getRepository(Season::class);
     $this->episodesRepository = $registry->getRepository(Episode::class);
     $this->languagesRepository = $registry->getRepository(Language::class);
     $this->charactersRepository = $registry->getRepository(Character::class);
     $this->scenariosDir = Helpers::expand('%appDir%/../scenarios', $container->getParameters());
 }
开发者ID:legendik,项目名称:DwarfSearch,代码行数:14,代码来源:ScreenplayImportCommand.php

示例6: loadConfiguration

 public function loadConfiguration()
 {
     // Cause we don't want merge arrays (annotations, interfaces, etc..)
     $config = $this->getCustomConfig($this->defaults);
     // Validate config
     Validators::assertField($config, 'dirs', 'array');
     Validators::assertField($config, 'annotations', 'array|null');
     Validators::assertField($config, 'interfaces', 'array|null');
     Validators::assertField($config, 'decorator', 'array');
     // Expand config (cause %appDir% etc..)
     $this->config = Helpers::expand($config, $this->getContainerBuilder()->parameters);
 }
开发者ID:minetro,项目名称:service-autoloader,代码行数:12,代码来源:ServiceAutoloadExtension.php

示例7: getSettings

 /**
  * @return array
  */
 public function getSettings()
 {
     if (method_exists($this, 'validateConfig')) {
         $config = $this->validateConfig($this->defaults, $this->config);
         $config['wwwDir'] = Nette\DI\Helpers::expand($config['wwwDir'], $this->getContainerBuilder()->parameters);
         $config['appDir'] = Nette\DI\Helpers::expand($config['appDir'], $this->getContainerBuilder()->parameters);
     } else {
         $config = $this->getConfig($this->defaults);
         // deprecated
     }
     return $config;
 }
开发者ID:vojtabiberle,项目名称:MediaStorage,代码行数:15,代码来源:Extension.php

示例8: beforeCompile

 /**
  * Method setings extension.
  */
 public function beforeCompile()
 {
     $builder = $this->getContainerBuilder();
     $this->validateConfig($this->defaults);
     $config = $this->getConfig($this->defaults);
     foreach ($builder->findByType('Nette\\Mail\\IMailer') as $name => $def) {
         $builder->removeDefinition($name);
     }
     if ($config['debugger'] && interface_exists('Tracy\\IBarPanel')) {
         $builder->addDefinition($this->prefix('panel'))->setClass('RM\\MailPanel')->addSetup('$newMessageTime', [$config['newMessageTime']])->addSetup('$show', [array_unique($config['show'])])->addSetup('$autoremove', [$config['autoremove']])->addSetup('$hideEmpty', [$config['hideEmpty']]);
     }
     $builder->addDefinition($this->prefix('mailer'))->setClass('RM\\FileMailer', [Helpers::expand($config['tempDir'], $builder->parameters)])->addSetup('@RM\\MailPanel::setFileMailer', ['@self'])->addSetup('@Tracy\\Bar::addPanel', [$this->prefix('@panel')]);
 }
开发者ID:newPOPE,项目名称:FileMailer,代码行数:16,代码来源:MailPanelExtension.php

示例9: loadConfiguration

 /**
  * @inheritDoc
  */
 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = Helpers::expand($this->getConfig() + $this->defaults, $builder->parameters);
     $this->setupConfigByExtensions($config);
     $this->assertConfig($config);
     $builder->parameters[$this->prefix('debug')] = !empty($config['debug']);
     $this->createMetadataDriver();
     $this->createConfigurationService($config);
     $this->createEventManager($config);
     $this->createConnection($config);
     $this->createEntityManager($config);
     $this->registerMetadata($config['metadata']);
     $this->registerEventSubscribers($config['eventSubscribers']);
 }
开发者ID:pt24,项目名称:doctrine,代码行数:18,代码来源:CompilerExtension.php

示例10: loadConfiguration

 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->validateConfig($this->defaults);
     // Add themes
     $params = [];
     $neon = new NeonAdapter();
     foreach (Finder::findFiles('theme.neon')->limitDepth(2)->from($config['themes']) as $file => $splfile) {
         // Parse config
         $expandConfig = ['themeDir' => dirname($splfile->getRealPath())];
         $themeConfig = Helpers::expand($neon->load($file), $expandConfig, TRUE);
         // Validate theme configs
         $this->validateConfig($this->themeDefaults, $themeConfig, 'themes');
         $this->validateConfig($this->themeDefaults['theme'], $themeConfig['theme'], 'theme');
         // Parse theme name
         $themeName = strtolower($themeConfig['theme']['name']);
         // Check duplicity
         if (array_key_exists($themeName, $params)) {
             throw new InvalidStateException('Theme "' . $themeName . '" is already defined.');
         }
         // Add to array
         $params[$themeName] = $themeConfig;
     }
     // Check if selected template is not null
     Validators::assertField($params, $config['theme'], NULL, 'template "%s"');
     $theme = $params[$config['theme']];
     // Add parameters to global parameters
     $builder->parameters['themes'] = [];
     $builder->parameters['themes']['theme'] = $theme['theme'];
     $builder->parameters['themes']['vars'] = $config['template'];
     $builder->parameters['themes']['output'] = $config['output'];
     // Add template model to container
     Compiler::parseServices($builder, ['services' => $theme['model']], $this->prefix('model'));
     // Add command manager (fake presenter)
     $builder->addDefinition($this->prefix('ui.manager'))->setClass('Generator\\UI\\CommandManager');
     // Add template factory
     $builder->addDefinition($this->prefix('latte.templateFactory'))->setClass('Generator\\Latte\\TemplateFactory')->setAutowired();
     // Add commands
     $builder->addDefinition($this->prefix('commands.info'))->setClass('Generator\\Commands\\InfoCommand')->setInject();
     $builder->addDefinition($this->prefix('commands.generate'))->setClass('Generator\\Commands\\GenerateCommand', [$builder->parameters['themes']])->setInject();
     $builder->addDefinition($this->prefix('commands.deploy'))->setClass('Generator\\Commands\\DeployCommand')->setInject();
     $builder->addDefinition($this->prefix('commands.error'))->setClass('Generator\\Commands\\ErrorCommand')->setInject();
 }
开发者ID:minetro,项目名称:ghpage,代码行数:43,代码来源:Extension.php

示例11: getSettings

 /**
  * @throws ImageStorageException
  * @return array
  */
 public function getSettings()
 {
     if (!$this->settings) {
         $config = $this->validateConfig($this->defaults);
         $config['wwwDir'] = Nette\DI\Helpers::expand($config['wwwDir'], $this->getContainerBuilder()->parameters);
         // Validation
         $quality = $config['quality'];
         if (!is_int($quality) || !Validators::isInRange($quality, [0, 100])) {
             throw new ImageStorageException('Quality must be an integer from 0 to 100.');
         }
         foreach ($config['events'] as $name => &$array) {
             Validators::assert($array, 'array');
         }
         foreach ($config['helpers'] as $name => $class) {
             if (!class_exists($class) || $class instanceof IHelper) {
                 throw new ImageStorageException("Helper {$name} must be instance of " . IHelper::class);
             }
         }
         $this->settings = $config;
     }
     return $this->settings;
 }
开发者ID:webchemistry,项目名称:images,代码行数:26,代码来源:ImagesExtension.php

示例12: parsePosts

 /**
  * @param array $files
  * @throws InvalidStateException
  * @return array
  */
 protected function parsePosts($files)
 {
     $posts = [];
     $postsIds = [];
     $decoder = new NeonAdapter();
     foreach ($files as $file) {
         // Decode file
         $config = $decoder->load($file);
         // Merge
         $post = Config\Helpers::merge($config, $this->scheme);
         // Check unique post id
         if (in_array($post['id'], $postsIds)) {
             throw new InvalidStateException('Duplicate post.id "' . $post['id'] . '"');
         }
         // Expand post scheme
         $post = Helpers::expand($post, ['file' => dirname($file)], TRUE);
         // Unify
         $post['post'] = realpath($post['post']);
         $posts[] = $post;
         $postsIds[] = $post['id'];
     }
     return $posts;
 }
开发者ID:minetro,项目名称:simple-blogger,代码行数:28,代码来源:StaticCollector.php

示例13: generateService

 /**
  * Generates body of service method.
  *
  * @return string
  */
 private function generateService($name)
 {
     $def = $this->definitions[$name];
     $parameters = $this->parameters;
     foreach ($this->expand($def->parameters) as $k => $v) {
         $v = explode(' ', is_int($k) ? $v : $k);
         $parameters[end($v)] = new PhpLiteral('$' . end($v));
     }
     $code = '$service = ' . $this->formatStatement(Helpers::expand($def->factory, $parameters, true)) . ";\n";
     $entity = $this->normalizeEntity($def->factory->entity);
     if ($def->class && $def->class !== $entity && !$this->getServiceName($entity)) {
         $code .= PhpHelpers::formatArgs("if (!\$service instanceof {$def->class}) {\n" . "\tthrow new Nette\\UnexpectedValueException(?);\n}\n", array("Unable to create service '{$name}', value returned by factory is not {$def->class} type."));
     }
     foreach ((array) $def->setup as $setup) {
         $setup = Helpers::expand($setup, $parameters, true);
         if (is_string($setup->entity) && strpbrk($setup->entity, ':@?') === false) {
             // auto-prepend @self
             $setup->entity = array("@{$name}", $setup->entity);
         }
         $code .= $this->formatStatement($setup, $name) . ";\n";
     }
     return $code .= 'return $service;';
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:28,代码来源:ContainerBuilder.php

示例14: parseServices

 /**
  * Parses section 'services' from (unexpanded) configuration file.
  * @return void
  */
 public static function parseServices(ContainerBuilder $builder, array $config, $namespace = NULL)
 {
     if (!empty($config['factories'])) {
         throw new Nette\DeprecatedException("Section 'factories' is deprecated, move definitions to section 'services' and append key 'autowired: no'.");
     }
     $services = isset($config['services']) ? $config['services'] : array();
     $depths = array();
     foreach ($services as $name => $def) {
         $path = array();
         while (Config\Helpers::isInheriting($def)) {
             $path[] = $def;
             $def = isset($services[$def[Config\Helpers::EXTENDS_KEY]]) ? $services[$def[Config\Helpers::EXTENDS_KEY]] : array();
             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 $origName => $def) {
         if ((string) (int) $origName === (string) $origName) {
             $postfix = $def instanceof Statement && is_string($def->getEntity()) ? '.' . $def->getEntity() : (is_scalar($def) ? ".{$def}" : '');
             $name = count($builder->getDefinitions()) + 1 . preg_replace('#\\W+#', '_', $postfix);
         } else {
             $name = ($namespace ? $namespace . '.' : '') . strtr($origName, '\\', '_');
         }
         $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(), NULL, $e);
         }
         if ($definition->getClass() === 'self' || $definition->getFactory() && $definition->getFactory()->getEntity() === 'self') {
             throw new Nette\DeprecatedException("Replace service definition '{$origName}: self' with '- {$origName}'.");
         }
     }
 }
开发者ID:DIPcom,项目名称:Sandmin,代码行数:56,代码来源:Compiler.php

示例15: generateContainer

 /**
  * @return string
  * @internal
  */
 public function generateContainer(DI\Compiler $compiler)
 {
     $loader = $this->createLoader();
     $compiler->addConfig(['parameters' => $this->parameters]);
     $fileInfo = [];
     foreach ($this->files as $info) {
         if (is_scalar($info[0])) {
             $fileInfo[] = "// source: {$info['0']} {$info['1']}";
             $info[0] = $loader->load($info[0], $info[1]);
         }
         $compiler->addConfig($this->fixCompatibility($info[0]));
     }
     $compiler->addDependencies($loader->getDependencies());
     $builder = $compiler->getContainerBuilder();
     $builder->addExcludedClasses($this->autowireExcludedClasses);
     foreach ($this->defaultExtensions as $name => $extension) {
         list($class, $args) = is_string($extension) ? [$extension, []] : $extension;
         if (class_exists($class)) {
             $args = DI\Helpers::expand($args, $this->parameters, TRUE);
             $compiler->addExtension($name, (new \ReflectionClass($class))->newInstanceArgs($args));
         }
     }
     $this->onCompile($this, $compiler);
     $classes = $compiler->compile();
     if (!empty($builder->parameters['container']['parent'])) {
         $classes[0]->setExtends($builder->parameters['container']['parent']);
     }
     return implode("\n", $fileInfo) . "\n\n" . implode("\n\n\n", $classes) . (($tmp = $builder->parameters['container']['class']) ? "\nclass {$tmp} extends {$builder->getClassName()} {}\n" : '');
 }
开发者ID:pt24,项目名称:bootstrap,代码行数:33,代码来源:Configurator.php


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