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


PHP Compiler::filterArguments方法代码示例

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


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

示例1: loadConfiguration

 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     $builder->addDefinition($this->prefix('helperSet'))->setClass('Symfony\\Component\\Console\\Helper\\HelperSet', array(array(new Nette\DI\Statement('Symfony\\Component\\Console\\Helper\\DialogHelper'), new Nette\DI\Statement('Symfony\\Component\\Console\\Helper\\FormatterHelper'), new Nette\DI\Statement('Symfony\\Component\\Console\\Helper\\ProgressHelper'), new Nette\DI\Statement('Kdyby\\Console\\Helpers\\PresenterHelper'))))->setInject(FALSE);
     $builder->addDefinition($this->prefix('application'))->setClass('Kdyby\\Console\\Application', array($config['name'], $config['version']))->addSetup('setHelperSet', array($this->prefix('@helperSet')))->setInject(FALSE);
     $builder->addDefinition($this->prefix('router'))->setClass('Kdyby\\Console\\CliRouter')->setAutowired(FALSE)->setInject(FALSE);
     $builder->getDefinition('router')->addSetup('Kdyby\\Console\\CliRouter::prependTo($service, ?)', array($this->prefix('@router')));
     $builder->getDefinition('nette.presenterFactory')->addSetup('if (method_exists($service, ?)) { $service->setMapping(array(? => ?)); } ' . 'elseif (property_exists($service, ?)) { $service->mapping[?] = ?; }', array('setMapping', 'Kdyby', 'KdybyModule\\*\\*Presenter', 'mapping', 'Kdyby', 'KdybyModule\\*\\*Presenter'));
     if (!empty($config['url'])) {
         if (!preg_match('~^https?://[^/]+\\.[a-z]+(/.*)?$~', $config['url'])) {
             throw new Nette\Utils\AssertionException("The url '{$config['url']}' is not valid, please use this format: 'http://domain.tld/path'.");
         }
         $builder->getDefinition('nette.httpRequestFactory')->setClass('Kdyby\\Console\\HttpRequestFactory')->addSetup('setFakeRequestUrl', array($config['url']));
     }
     $builder->addDefinition($this->prefix('dicHelper'))->setClass('Kdyby\\Console\\ContainerHelper')->addTag(self::HELPER_TAG, 'dic');
     Nette\Utils\Validators::assert($config, 'array');
     foreach ($config['commands'] as $command) {
         $def = $builder->addDefinition($this->prefix('command.' . md5(Nette\Utils\Json::encode($command))));
         list($def->factory) = Nette\DI\Compiler::filterArguments(array(is_string($command) ? new Nette\DI\Statement($command) : $command));
         if (class_exists($def->factory->entity)) {
             $def->class = $def->factory->entity;
         }
         $def->setAutowired(FALSE);
         $def->setInject(FALSE);
         $def->addTag(self::COMMAND_TAG);
     }
 }
开发者ID:pixuin,项目名称:console,代码行数:28,代码来源:ConsoleExtension.php

示例2: loadConfiguration

 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     $helperClasses = array('Symfony\\Component\\Console\\Helper\\FormatterHelper', 'Symfony\\Component\\Console\\Helper\\QuestionHelper', 'Kdyby\\Console\\Helpers\\PresenterHelper');
     $helperClasses = array_map(function ($class) {
         return new Nette\DI\Statement($class);
     }, $helperClasses);
     if (class_exists('Symfony\\Component\\Console\\Helper\\ProgressHelper')) {
         $helperClasses[] = new Nette\DI\Statement('Symfony\\Component\\Console\\Helper\\ProgressHelper', array(false));
     }
     if (class_exists('Symfony\\Component\\Console\\Helper\\DialogHelper')) {
         $helperClasses[] = new Nette\DI\Statement('Symfony\\Component\\Console\\Helper\\DialogHelper', array(false));
     }
     $builder->addDefinition($this->prefix('helperSet'))->setClass('Symfony\\Component\\Console\\Helper\\HelperSet', array($helperClasses))->setInject(FALSE);
     $builder->addDefinition($this->prefix('application'))->setClass('Kdyby\\Console\\Application', array($config['name'], $config['version']))->addSetup('setHelperSet', array($this->prefix('@helperSet')))->addSetup('injectServiceLocator')->setInject(FALSE);
     $builder->addDefinition($this->prefix('dicHelper'))->setClass('Kdyby\\Console\\ContainerHelper')->addTag(self::TAG_HELPER, 'dic');
     if ($config['disabled']) {
         return;
     }
     $builder->addDefinition($this->prefix('router'))->setClass('Kdyby\\Console\\CliRouter')->setAutowired(FALSE)->setInject(FALSE);
     Nette\Utils\Validators::assert($config, 'array');
     foreach ($config['commands'] as $command) {
         $def = $builder->addDefinition($this->prefix('command.' . md5(Nette\Utils\Json::encode($command))));
         list($def->factory) = Nette\DI\Compiler::filterArguments(array(is_string($command) ? new Nette\DI\Statement($command) : $command));
         if (class_exists($def->factory->entity)) {
             $def->class = $def->factory->entity;
         }
         $def->setAutowired(FALSE);
         $def->setInject(FALSE);
         $def->addTag(self::TAG_COMMAND);
     }
 }
开发者ID:NetteCamp,项目名称:2015-nextras-orm-twitter,代码行数:33,代码来源:ConsoleExtension.php

示例3: afterCompile

 public function afterCompile(Nette\PhpGenerator\ClassType $class)
 {
     $initialize = $class->getMethod('initialize');
     $builder = $this->getContainerBuilder();
     $options = $this->config;
     unset($options['bar'], $options['blueScreen']);
     if (isset($options['logSeverity'])) {
         $res = 0;
         foreach ((array) $options['logSeverity'] as $level) {
             $res |= is_int($level) ? $level : constant($level);
         }
         $options['logSeverity'] = $res;
     }
     foreach ($options as $key => $value) {
         if ($value !== NULL) {
             $key = ($key === 'fromEmail' ? 'getLogger()->' : '$') . $key;
             $initialize->addBody($builder->formatPhp('Tracy\\Debugger::' . $key . ' = ?;', Nette\DI\Compiler::filterArguments([$value])));
         }
     }
     $logger = $builder->getDefinition($this->prefix('logger'));
     if ($logger->getFactory()->getEntity() !== 'Tracy\\Debugger::getLogger') {
         $initialize->addBody($builder->formatPhp('Tracy\\Debugger::setLogger(?);', [$logger]));
     }
     if ($this->debugMode) {
         foreach ((array) $this->config['bar'] as $item) {
             $initialize->addBody($builder->formatPhp('$this->getService(?)->addPanel(?);', Nette\DI\Compiler::filterArguments([$this->prefix('bar'), is_string($item) ? new Nette\DI\Statement($item) : $item])));
         }
         if (!$this->cliMode) {
             $initialize->addBody('if ($tmp = $this->getByType("Nette\\Http\\Session", FALSE)) { $tmp->start(); Tracy\\Debugger::dispatch(); };');
         }
     }
     foreach ((array) $this->config['blueScreen'] as $item) {
         $initialize->addBody($builder->formatPhp('$this->getService(?)->addPanel(?);', Nette\DI\Compiler::filterArguments([$this->prefix('blueScreen'), $item])));
     }
 }
开发者ID:manGoweb,项目名称:mnamGo,代码行数:35,代码来源:TracyExtension.php

示例4: afterCompile

 /**
  * @param Code\ClassType $class
  */
 public function afterCompile(Code\ClassType $class)
 {
     $container = $this->getContainerBuilder();
     $init = $class->methods['initialize'];
     /** @var Code\Method $init */
     $blueScreen = 'Nette\\Diagnostics\\Debugger::' . (method_exists('Nette\\Diagnostics\\Debugger', 'getBlueScreen') ? 'getBlueScreen()' : '$blueScreen');
     $init->addBody($container->formatPhp($blueScreen . '->addPanel(?);', Nette\DI\Compiler::filterArguments(array('Kdyby\\PayPalExpress\\Diagnostics\\Panel::renderException'))));
 }
开发者ID:Hajneej,项目名称:PayPalExpress,代码行数:11,代码来源:PayPalExtension.php

示例5: getDbalFactory

 private function getDbalFactory($dbal)
 {
     if ($dbal instanceof Nette\DI\Statement) {
         return Nette\DI\Compiler::filterArguments([$dbal])[0];
     } elseif (is_string($dbal) && isset($this->dbals[$dbal])) {
         return $this->dbals[$dbal];
     } else {
         return NULL;
     }
 }
开发者ID:NetteCamp,项目名称:2015-nextras-orm-twitter,代码行数:10,代码来源:MigrationsExtension.php

示例6: buildDefinition

 /**
  * @param string $value
  * @return ServiceDefinition|NULL
  */
 protected function buildDefinition($value)
 {
     if ($value === NULL) {
         return NULL;
     }
     $builder = $this->getContainerBuilder();
     $definition = $builder->addDefinition($this->prefix(md5($value)));
     list($definition->factory) = Compiler::filterArguments(array(is_string($value) ? new Statement($value) : $value));
     list($resolverClass) = (array) $builder->normalizeEntity($definition->getFactory()->getEntity());
     if (class_exists($resolverClass)) {
         $definition->setClass($resolverClass);
     }
     return $definition;
 }
开发者ID:darkphoenixff4,项目名称:DoctrineBehaviors,代码行数:18,代码来源:BehaviorExtension.php

示例7: loadJobs

 protected function loadJobs()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     foreach ($config['jobs'] as $subscriber) {
         $def = $builder->addDefinition($this->prefix('job.' . md5(Json::encode($subscriber))));
         list($def->factory) = Compiler::filterArguments(array(is_string($subscriber) ? new Statement($subscriber) : $subscriber));
         list($subscriberClass) = (array) $builder->normalizeEntity($def->factory->entity);
         if (class_exists($subscriberClass)) {
             $def->class = $subscriberClass;
         }
         $def->setAutowired(false);
         $def->addTag($config['cronJobTag']);
     }
 }
开发者ID:foowie,项目名称:cron,代码行数:15,代码来源:CronExtension.php

示例8: loadConfiguration

 public function loadConfiguration()
 {
     $container = $this->getContainerBuilder();
     $config = $this->compiler->getConfig();
     if (isset($config['nette']['database'])) {
         // back compatibility
         $config = $config['nette']['database'];
         $prefix = 'nette.';
     } else {
         $config = isset($config[$this->name]) ? $config[$this->name] : array();
         $prefix = '';
     }
     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, 'database');
         $info += array('autowired' => $autowired) + $this->databaseDefaults;
         $autowired = FALSE;
         foreach ((array) $info['options'] as $key => $value) {
             if (preg_match('#^PDO::\\w+\\z#', $key)) {
                 unset($info['options'][$key]);
                 $info['options'][constant($key)] = $value;
             }
         }
         $connection = $container->addDefinition($prefix . $this->prefix($name))->setClass('Nette\\Database\\Connection', array($info['dsn'], $info['user'], $info['password'], $info['options']))->setAutowired($info['autowired'])->addSetup('Tracy\\Debugger::getBlueScreen()->addPanel(?)', array('Nette\\Bridges\\DatabaseTracy\\ConnectionPanel::renderException'));
         if (!$info['reflection']) {
             $reflection = NULL;
         } elseif (is_string($info['reflection'])) {
             $reflection = new Nette\DI\Statement(preg_match('#^[a-z]+\\z#', $info['reflection']) ? 'Nette\\Database\\Reflection\\' . ucfirst($info['reflection']) . 'Reflection' : $info['reflection'], strtolower($info['reflection']) === 'discovered' ? array($connection) : array());
         } else {
             $tmp = Nette\DI\Compiler::filterArguments(array($info['reflection']));
             $reflection = reset($tmp);
         }
         $container->addDefinition($prefix . $this->prefix("{$name}.context"))->setClass('Nette\\Database\\Context', array($connection, $reflection))->setAutowired($info['autowired']);
         if ($container->parameters['debugMode'] && $info['debugger']) {
             $connection->addSetup('Nette\\Database\\Helpers::createDebugPanel', array($connection, !empty($info['explain']), $name));
         }
     }
 }
开发者ID:prcharom,项目名称:w-pps-reality,代码行数:44,代码来源:DatabaseExtension.php

示例9: afterCompile

 public function afterCompile(Nette\PhpGenerator\ClassType $class)
 {
     $container = $this->getContainerBuilder();
     if ($container->parameters['debugMode']) {
         $initialize = $class->methods['initialize'];
         foreach ($this->compiler->getExtensions() as $extension) {
             if ($extension instanceof ITracyBarPanelsProvider) {
                 foreach ($extension->getTracyBarPanels() as $item) {
                     $initialize->addBody($container->formatPhp('Nette\\Diagnostics\\Debugger::getBar()->addPanel(?);', Nette\DI\Compiler::filterArguments(array(is_string($item) ? new Nette\DI\Statement($item) : $item))));
                 }
             }
             if ($extension instanceof ITracyPanelsProvider) {
                 foreach ($extension->getTracyPanels() as $item) {
                     $initialize->addBody($container->formatPhp('Nette\\Diagnostics\\Debugger::getBlueScreen()->addPanel(?);', Nette\DI\Compiler::filterArguments(array($item))));
                 }
             }
         }
     }
 }
开发者ID:rixxi,项目名称:modular,代码行数:19,代码来源:ModularExtension.php

示例10: loadConfiguration

 /**
  * @inheritdoc
  */
 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->validateConfig($this->defaults);
     Validators::assertField($config, 'debugger', 'bool');
     $builder->addDefinition($this->prefix('panel'))->setClass('Tracy\\IBarPanel')->setFactory('Ark8\\Security\\Tracy\\AuthorizatorPanel')->setAutowired(FALSE);
     $builder->addDefinition($this->prefix('resourceFactory'))->setClass('Ark8\\Security\\Resources\\ResourceFactory');
     $builder->addDefinition($this->prefix('validator'))->setClass('Ark8\\Security\\Validator');
     Validators::assertField($config, 'policy', 'bool');
     $builder->addDefinition($this->prefix('authorizator'))->setClass('Nette\\Security\\IAuthorizator')->setFactory('Ark8\\Security\\Authorizators\\AuthorizatorList', [$config['policy']])->setAutowired(FALSE);
     // will be set to true later
     $builder->addDefinition($this->prefix('proxy'))->setClass('Nette\\Security\\IAuthorizator')->setFactory('Ark8\\Security\\Authorizators\\ProxyAuthorizator')->setAutowired(FALSE)->addTag($this->prefix(self::AUTHORIZATOR_TAG), -1);
     Validators::assertField($config, 'authorizators', 'array');
     $priority = count($config['authorizators']);
     foreach ($config['authorizators'] as $class) {
         list($factory) = Compiler::filterArguments([is_string($class) ? new Statement($class) : $class]);
         $builder->addDefinition($this->prefix('authorizator.' . $priority))->setClass('Nette\\Security\\IAuthorizator')->setFactory($factory)->setAutowired(FALSE)->addTag($this->prefix(self::AUTHORIZATOR_TAG), $priority--);
     }
 }
开发者ID:ark8,项目名称:security,代码行数:22,代码来源:SecurityExtension.php

示例11: afterCompile

 public function afterCompile(Nette\PhpGenerator\ClassType $class)
 {
     $initialize = $class->getMethod('initialize');
     $container = $this->getContainerBuilder();
     $options = $this->config;
     unset($options['bar'], $options['blueScreen']);
     foreach ($options as $key => $value) {
         if ($value !== NULL) {
             $initialize->addBody('Tracy\\Debugger::$? = ?;', array($key, $value));
         }
     }
     if ($this->debugMode) {
         foreach ((array) $this->config['bar'] as $item) {
             $initialize->addBody($container->formatPhp('$this->getService(?)->addPanel(?);', Nette\DI\Compiler::filterArguments(array($this->prefix('bar'), is_string($item) ? new Nette\DI\Statement($item) : $item))));
         }
     }
     foreach ((array) $this->config['blueScreen'] as $item) {
         $initialize->addBody($container->formatPhp('$this->getService(?)->addPanel(?);', Nette\DI\Compiler::filterArguments(array($this->prefix('blueScreen'), $item))));
     }
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:20,代码来源:TracyExtension.php

示例12: loadConfiguration

 public function loadConfiguration()
 {
     parent::loadConfiguration();
     $builder = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     Nette\Utils\Validators::assert($config, 'array');
     $contentsArguments = [$config['configurationDirectory'], $config['logDirectory']];
     if (!is_null($config['logDirectory'])) {
         $contentsArguments[2] = '@tracy.logger';
     }
     $builder->addDefinition($this->prefix('contents'))->setClass('Trejjam\\Contents\\Contents')->setArguments($contentsArguments);
     foreach ($config['subTypes'] as $subTypeName => $subType) {
         $def = $builder->addDefinition($this->prefix('contents.' . md5(Nette\Utils\Json::encode($subType))));
         $def->addSetup('setName', [$subTypeName]);
         $def->setFactory(Nette\DI\Compiler::filterArguments([is_string($subType) ? new Nette\DI\Statement($subType) : $subType])[0]);
         $def->setAutowired(FALSE);
         $def->setInject(FALSE);
         $def->addTag(self::TAG_CONTENTS_SUBTYPES);
     }
 }
开发者ID:trejjam,项目名称:contents,代码行数:20,代码来源:ContentsExtension.php

示例13: setupDatabase

 private function setupDatabase($config, $name)
 {
     $container = $this->getContainerBuilder();
     foreach ((array) $config['options'] as $key => $value) {
         if (preg_match('#^PDO::\\w+\\z#', $key)) {
             unset($config['options'][$key]);
             $config['options'][constant($key)] = $value;
         }
     }
     $connection = $container->addDefinition($this->prefix("{$name}.connection"))->setClass(Nette\Database\Connection::class, [$config['dsn'], $config['user'], $config['password'], $config['options']])->setAutowired($config['autowired']);
     $structure = $container->addDefinition($this->prefix("{$name}.structure"))->setClass(Nette\Database\Structure::class)->setArguments([$connection])->setAutowired($config['autowired']);
     if (!empty($config['reflection'])) {
         $conventionsServiceName = 'reflection';
         $config['conventions'] = $config['reflection'];
         if (strtolower($config['conventions']) === 'conventional') {
             $config['conventions'] = 'Static';
         }
     } else {
         $conventionsServiceName = 'conventions';
     }
     if (!$config['conventions']) {
         $conventions = NULL;
     } elseif (is_string($config['conventions'])) {
         $conventions = $container->addDefinition($this->prefix("{$name}.{$conventionsServiceName}"))->setClass(preg_match('#^[a-z]+\\z#i', $config['conventions']) ? 'Nette\\Database\\Conventions\\' . ucfirst($config['conventions']) . 'Conventions' : $config['conventions'])->setArguments(strtolower($config['conventions']) === 'discovered' ? [$structure] : [])->setAutowired($config['autowired']);
     } else {
         $tmp = Nette\DI\Compiler::filterArguments([$config['conventions']]);
         $conventions = reset($tmp);
     }
     $container->addDefinition($this->prefix("{$name}.context"))->setClass(Nette\Database\Context::class, [$connection, $structure, $conventions])->setAutowired($config['autowired']);
     if ($config['debugger']) {
         $connection->addSetup('@Tracy\\BlueScreen::addPanel', ['Nette\\Bridges\\DatabaseTracy\\ConnectionPanel::renderException']);
         if ($this->debugMode) {
             $connection->addSetup('Nette\\Database\\Helpers::createDebugPanel', [$connection, !empty($config['explain']), $name]);
         }
     }
     if ($this->name === 'database') {
         $container->addAlias($this->prefix($name), $this->prefix("{$name}.connection"));
         $container->addAlias("nette.database.{$name}", $this->prefix($name));
         $container->addAlias("nette.database.{$name}.context", $this->prefix("{$name}.context"));
     }
 }
开发者ID:ricco24,项目名称:database,代码行数:41,代码来源:DatabaseExtension.php

示例14: loadConfiguration

 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     $helperClasses = array('Symfony\\Component\\Console\\Helper\\DialogHelper', 'Symfony\\Component\\Console\\Helper\\FormatterHelper', 'Symfony\\Component\\Console\\Helper\\QuestionHelper', 'Kdyby\\Console\\Helpers\\PresenterHelper');
     if (class_exists('Symfony\\Component\\Console\\Helper\\ProgressHelper')) {
         $helperClasses[] = 'Symfony\\Component\\Console\\Helper\\ProgressHelper';
     }
     $helperClasses = array_map(function ($class) {
         return new Nette\DI\Statement($class);
     }, $helperClasses);
     $builder->addDefinition($this->prefix('helperSet'))->setClass('Symfony\\Component\\Console\\Helper\\HelperSet', array($helperClasses))->setInject(FALSE);
     $builder->addDefinition($this->prefix('application'))->setClass('Kdyby\\Console\\Application', array($config['name'], $config['version']))->addSetup('setHelperSet', array($this->prefix('@helperSet')))->addSetup('injectServiceLocator')->setInject(FALSE);
     $builder->addDefinition($this->prefix('dicHelper'))->setClass('Kdyby\\Console\\ContainerHelper')->addTag(self::HELPER_TAG, 'dic');
     if ($config['disabled']) {
         return;
     }
     if (PHP_SAPI === 'cli') {
         $builder->getDefinition('application')->addSetup('$self = $this; $service->onError[] = function ($app, $e) use ($self) {' . "\n" . "\t" . '$app->errorPresenter = ?;' . "\n" . "\t" . '$app->onShutdown[] = function () { exit(?); };' . "\n" . "\t" . '$self->getService(?)->handleException($e); ' . "\n" . '}', array(FALSE, 254, $this->prefix('application')));
     }
     $builder->addDefinition($this->prefix('router'))->setClass('Kdyby\\Console\\CliRouter')->setAutowired(FALSE)->setInject(FALSE);
     $builder->getDefinition('router')->addSetup('Kdyby\\Console\\CliRouter::prependTo($service, ?)', array($this->prefix('@router')));
     $builder->getDefinition('nette.presenterFactory')->addSetup('if (method_exists($service, ?)) { $service->setMapping(array(? => ?)); } ' . 'elseif (property_exists($service, ?)) { $service->mapping[?] = ?; }', array('setMapping', 'Kdyby', 'KdybyModule\\*\\*Presenter', 'mapping', 'Kdyby', 'KdybyModule\\*\\*Presenter'));
     if (!empty($config['url'])) {
         if (!preg_match('~^https?://[^/]+(/.*)?$~', $config['url'])) {
             throw new Nette\Utils\AssertionException("The url '{$config['url']}' is not valid, please use this format: 'http://domain.tld/path'.");
         }
         $builder->getDefinition('nette.httpRequestFactory')->setClass('Kdyby\\Console\\HttpRequestFactory')->addSetup('setFakeRequestUrl', array($config['url']));
     }
     Nette\Utils\Validators::assert($config, 'array');
     foreach ($config['commands'] as $command) {
         $def = $builder->addDefinition($this->prefix('command.' . md5(Nette\Utils\Json::encode($command))));
         list($def->factory) = Nette\DI\Compiler::filterArguments(array(is_string($command) ? new Nette\DI\Statement($command) : $command));
         if (class_exists($def->factory->entity)) {
             $def->class = $def->factory->entity;
         }
         $def->setAutowired(FALSE);
         $def->setInject(FALSE);
         $def->addTag(self::COMMAND_TAG);
     }
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:41,代码来源:ConsoleExtension.php

示例15: loadConfiguration

 public function loadConfiguration()
 {
     $container = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     Validators::assert($config['timestampStorage'], 'string|object|null', 'Timestamp storage definition');
     Validators::assert($config['maxExecutionTime'], 'integer|null', 'Script max execution time');
     Validators::assert($config['criticalSectionTempDir'], 'string', 'Critical section files directory path');
     if ($config['timestampStorage'] === NULL) {
         $storageServiceName = $container->getByType('stekycz\\Cronner\\ITimestampStorage');
         $storage = $this->createTimestampStorage($container);
         if ($storageServiceName) {
             $storage->setFactory('@' . $storageServiceName);
         } else {
             $storage->setClass(self::DEFAULT_STORAGE_CLASS, array($container->expand(self::DEFAULT_STORAGE_DIRECTORY)));
         }
     } else {
         $storage = $this->createTimestampStorage($container);
         if (is_string($config['timestampStorage']) && $container->getServiceName($config['timestampStorage'])) {
             $storage->setFactory($config['timestampStorage']);
         } else {
             $storage->setClass($config['timestampStorage']->entity, $config['timestampStorage']->arguments);
         }
     }
     $criticalSection = $container->addDefinition($this->prefix("criticalSection"))->setClass('stekycz\\Cronner\\CriticalSection', array($config['criticalSectionTempDir']))->setAutowired(FALSE)->setInject(FALSE);
     $runner = $container->addDefinition($this->prefix('runner'))->setClass('stekycz\\Cronner\\Cronner', array($storage, $criticalSection, $config['maxExecutionTime'], array_key_exists('debugMode', $config) ? !$config['debugMode'] : TRUE));
     Validators::assert($config['tasks'], 'array');
     foreach ($config['tasks'] as $task) {
         $def = $container->addDefinition($this->prefix('task.' . md5(Json::encode($task))));
         list($def->factory) = Compiler::filterArguments(array(is_string($task) ? new Statement($task) : $task));
         if (class_exists($def->factory->entity)) {
             $def->class = $def->factory->entity;
         }
         $def->setAutowired(FALSE);
         $def->setInject(FALSE);
         $def->addTag(self::TASKS_TAG);
     }
     if ($config['bar'] && class_exists('Tracy\\Bar')) {
         $container->addDefinition($this->prefix('bar'))->setClass('stekycz\\Cronner\\Bar\\Tasks', array($this->prefix('@runner'), $this->prefix('@timestampStorage')));
     }
 }
开发者ID:stekycz,项目名称:cronner,代码行数:40,代码来源:CronnerExtension.php


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