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


PHP DI\Helpers类代码示例

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


在下文中一共展示了Helpers类的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: beforeCompile

 public function beforeCompile()
 {
     foreach ($this->getConfig() as $class => $info) {
         $info = $this->validateConfig($this->defaults, $info, $this->prefix($class));
         if ($info['inject'] !== NULL) {
             $info['tags'][InjectExtension::TAG_INJECT] = $info['inject'];
         }
         $info = Nette\DI\Helpers::filterArguments($info);
         $this->addSetups($class, (array) $info['setup']);
         $this->addTags($class, (array) $info['tags']);
     }
 }
开发者ID:sallyx,项目名称:di,代码行数:12,代码来源:DecoratorExtension.php

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

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

示例10: run

	/**
	 * @return Nette\Application\IResponse
	 */
	public function run(Application\Request $request)
	{
		$this->request = $request;

		if ($this->httpRequest && $this->router && !$this->httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
			$refUrl = clone $this->httpRequest->getUrl();
			$url = $this->router->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
			if ($url !== NULL && !$this->httpRequest->getUrl()->isEqual($url)) {
				return new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY);
			}
		}

		$params = $request->getParameters();
		if (!isset($params['callback'])) {
			throw new Application\BadRequestException('Parameter callback is missing.');
		}
		$params['presenter'] = $this;
		$callback = $params['callback'];
		$reflection = Nette\Utils\Callback::toReflection(Nette\Utils\Callback::check($callback));
		$params = Application\UI\PresenterComponentReflection::combineArgs($reflection, $params);

		if ($this->context) {
			foreach ($reflection->getParameters() as $param) {
				if ($param->getClassName()) {
					unset($params[$param->getPosition()]);
				}
			}

			$params = Nette\DI\Helpers::autowireArguments($reflection, $params, $this->context);
			$params['presenter'] = $this;
		}

		$response = call_user_func_array($callback, $params);

		if (is_string($response)) {
			$response = array($response, array());
		}
		if (is_array($response)) {
			list($templateSource, $templateParams) = $response;
			$response = $this->createTemplate()->setParameters($templateParams);
			if (!$templateSource instanceof \SplFileInfo) {
				$response->getLatte()->setLoader(new Latte\Loaders\StringLoader);
			}
			$response->setFile($templateSource);
		}
		if ($response instanceof Application\UI\ITemplate) {
			return new Responses\TextResponse($response);
		} else {
			return $response;
		}
	}
开发者ID:nakoukal,项目名称:fakturace,代码行数:54,代码来源:MicroPresenter.php

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

示例12: injectByProperties

 private function injectByProperties(Presenter $presenter)
 {
     if (class_exists(InjectExtension::class)) {
         /** @noinspection PhpInternalEntityUsedInspection */
         $properties = InjectExtension::getInjectProperties(get_class($presenter));
         // Nette 2.3+
     } else {
         $properties = Helpers::getInjectProperties(new ClassType($presenter));
         // Nette 2.2
     }
     foreach ($properties as $property => $type) {
         if (isset($this->dependencies['@' . $property])) {
             $presenter->{$property} = $this->dependencies['@' . $property];
         } elseif (isset($this->dependencies[$property])) {
             $presenter->{$property} = $this->dependencies[$property];
         }
     }
 }
开发者ID:instante,项目名称:php-test-suite,代码行数:18,代码来源:DependencyContainer.php

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

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

示例15: createComponent

 /**
  * @param $name
  * @return Nette\ComponentModel\IComponent
  * @throws Nette\UnexpectedValueException
  */
 public function createComponent($name)
 {
     $sl = $this->getServiceLocatorForFactories();
     $ucname = ucfirst($name);
     $method = 'createComponent' . $ucname;
     if ($ucname !== $name && method_exists($this, $method)) {
         $reflection = $this->getReflection()->getMethod($method);
         if ($reflection->getName() !== $method) {
             return;
         }
         $parameters = $reflection->parameters;
         $args = array();
         if (($first = reset($parameters)) && !$first->className) {
             $args[] = $name;
         }
         $args = Nette\DI\Helpers::autowireArguments($reflection, $args, $sl);
         $component = call_user_func_array(array($this, $method), $args);
         if (!$component instanceof Nette\ComponentModel\IComponent && !isset($this->components[$name])) {
             throw new Nette\UnexpectedValueException("Method {$reflection} did not return or create the desired component.");
         }
         return $component;
     }
 }
开发者ID:matej21,项目名称:nette-autowire-component-factories,代码行数:28,代码来源:AutowireComponentFactories.php


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