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


PHP Validators::assert方法代码示例

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


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

示例1: setHeader

 /**
  * Sets a header.
  * @param  string
  * @param  string|array  value or pair email => name
  * @param  bool
  * @return self
  */
 public function setHeader($name, $value, $append = FALSE)
 {
     if (!$name || preg_match('#[^a-z0-9-]#i', $name)) {
         throw new Nette\InvalidArgumentException("Header name must be non-empty alphanumeric string, '{$name}' given.");
     }
     if ($value == NULL) {
         // intentionally ==
         if (!$append) {
             unset($this->headers[$name]);
         }
     } elseif (is_array($value)) {
         // email
         $tmp =& $this->headers[$name];
         if (!$append || !is_array($tmp)) {
             $tmp = array();
         }
         foreach ($value as $email => $recipient) {
             if ($recipient !== NULL && !Strings::checkEncoding($recipient)) {
                 Nette\Utils\Validators::assert($recipient, 'unicode', "header '{$name}'");
             }
             if (preg_match('#[\\r\\n]#', $recipient)) {
                 throw new Nette\InvalidArgumentException('Name must not contain line separator.');
             }
             Nette\Utils\Validators::assert($email, 'email', "header '{$name}'");
             $tmp[$email] = $recipient;
         }
     } else {
         $value = (string) $value;
         if (!Strings::checkEncoding($value)) {
             throw new Nette\InvalidArgumentException('Header is not valid UTF-8 string.');
         }
         $this->headers[$name] = preg_replace('#[\\r\\n]+#', ' ', $value);
     }
     return $this;
 }
开发者ID:pdostal,项目名称:nette-blog,代码行数:42,代码来源:MimePart.php

示例2: assertGithubRepositoryUrl

 /**
  * @param string
  */
 public static function assertGithubRepositoryUrl($url)
 {
     Validators::assert($url, 'string', 'url');
     if (!static::isGithubRepositoryUrl($url)) {
         throw new \Nette\Utils\AssertionException('The url is not valid GitHub repository URL.');
     }
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:10,代码来源:UrlsHelper.php

示例3: loadConfiguration

 public function loadConfiguration()
 {
     $config = $this->getConfig($this->defaults);
     Validators::assert($config['parameters'], 'array');
     $parameters = array();
     foreach ($config['parameters'] as $name => $value) {
         self::assertEnvName($name);
         self::assertEnvValue($value, $name);
         $parameters[$name] = $value;
     }
     Validators::assert($config['whitelist'], 'bool');
     if (strpos(ini_get('variables_order'), 'E') === TRUE) {
         foreach ($_ENV as $name => $value) {
             if ($config['whitelist'] && !isset($parameters[$name])) {
                 continue;
             }
             self::assertEnvName($name);
             self::assertEnvValue($value, $name);
             $parameters[$name] = $value;
         }
     } else {
         foreach (array_keys($config['parameters']) as $name) {
             if (($value = getenv($name)) !== FALSE) {
                 $parameters[$name] = $value;
             }
         }
     }
     $this->getContainerBuilder()->parameters += array(self::PARAMETER_CONTAINER => $parameters);
 }
开发者ID:rixxi,项目名称:env,代码行数:29,代码来源:EnvExtension.php

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

示例5: 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');
     $storage = $container->addDefinition($this->prefix('timestampStorage'))->setAutowired(FALSE)->setInject(FALSE);
     if ($config['timestampStorage'] === NULL) {
         $storageServiceName = $container->getByType('stekycz\\Cronner\\ITimestampStorage');
         if ($storageServiceName) {
             $storage->setFactory('@' . $storageServiceName);
         } else {
             $storage->setClass(self::DEFAULT_STORAGE_CLASS, array(self::DEFAULT_STORAGE_DIRECTORY));
         }
     } else {
         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));
     foreach (array_keys($container->findByTag(self::TASKS_TAG)) as $serviceName) {
         $runner->addSetup('addTasks', array('@' . $serviceName));
     }
 }
开发者ID:duskohu,项目名称:Cronner,代码行数:28,代码来源:CronnerExtension.php

示例6: loadConfiguration

 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     $builder->addDefinition($this->prefix('expressionLanguage'))->setClass('Zycon42\\Security\\Authorization\\ExpressionLanguage')->setInject(FALSE);
     Validators::assertField($config['decisionManager'], 'strategy', 'string');
     Validators::assertField($config['decisionManager'], 'allowIfAllAbstain', 'bool');
     Validators::assertField($config['decisionManager'], 'allowIfEqualGrantedDenied', 'bool');
     $builder->addDefinition($this->prefix('decisionManager'))->setImplementType('Zycon42\\Security\\Authorization\\IAccessDecisionManager')->setClass('Zycon42\\Security\\Authorization\\AccessDecisionManager', $config['decisionManager'])->setInject(FALSE);
     $builder->addDefinition($this->prefix('securityContext'))->setImplementType('Zycon42\\Security\\ISecurityContext')->setClass('Zycon42\\Security\\SecurityContext')->setInject(FALSE);
     $builder->addDefinition($this->prefix('expressionEvaluator'))->setClass('Zycon42\\Security\\Application\\ExpressionEvaluator')->setInject(FALSE);
     $builder->addDefinition($this->prefix('presenterRequirementsChecker'))->setClass('Zycon42\\Security\\Application\\PresenterRequirementsChecker')->setInject(FALSE);
     $roleHierarchyUsed = false;
     if ($config['roleHierarchy'] != FALSE) {
         Validators::assert($config['roleHierarchy'], 'array');
         $roleHierarchyUsed = true;
         // When there's string in roleHierarchy value convert it to array
         foreach ($config['roleHierarchy'] as $main => $roles) {
             if (!is_array($roles)) {
                 $config['roleHierarchy'][$main] = [$roles];
             }
         }
         $builder->addDefinition($this->prefix('roleHierarchy'))->setImplementType('Zycon42\\Security\\Role\\IRoleHierarchy')->setClass('Zycon42\\Security\\Role\\RoleHierarchy')->addSetup('setHierarchy', [$config['roleHierarchy']])->setInject(FALSE);
     }
     if ($config['voters'][self::VOTER_ROLE]) {
         $class = $roleHierarchyUsed ? 'RoleHierarchyVoter' : 'RoleVoter';
         $builder->addDefinition($this->prefix('voters.' . self::VOTER_ROLE))->setClass('Zycon42\\Security\\Authorization\\Voters\\' . $class)->addTag(self::TAG_VOTER)->setInject(FALSE);
     }
     if ($config['voters'][self::VOTER_EXPRESSION]) {
         $builder->addDefinition($this->prefix('voters.' . self::VOTER_EXPRESSION))->setClass('Zycon42\\Security\\Authorization\\Voters\\ExpressionVoter')->addTag(self::TAG_VOTER)->setInject(FALSE);
     }
     if ($config['voters'][self::VOTER_AUTHENTICATED]) {
         $builder->addDefinition($this->prefix('voters.' . self::VOTER_AUTHENTICATED))->setClass('Zycon42\\Security\\Authorization\\Voters\\AuthenticatedVoter')->addTag(self::TAG_VOTER)->setInject(FALSE);
     }
 }
开发者ID:zycon42,项目名称:security,代码行数:35,代码来源:SecurityExtension.php

示例7: loadConfiguration

 public function loadConfiguration()
 {
     $this->validateConfig($this->defaults);
     Validators::assertField($this->config, 'firewalls', 'array');
     foreach ($this->compiler->getExtensions('Arachne\\Security\\DI\\FirewallProviderInterface') as $extension) {
         $firewalls = $extension->getFirewalls();
         Validators::assert($firewalls, 'array');
         $this->config['firewalls'] = array_merge($this->config['firewalls'], $firewalls);
     }
     foreach ($this->config['firewalls'] as $firewall => $class) {
         if (!is_string($firewall)) {
             $this->addFirewall($class);
         } else {
             $this->addFirewall($firewall, $class);
         }
     }
     if ($extension = $this->getExtension('Arachne\\DIHelpers\\DI\\ResolversExtension', false)) {
         $extension->add(self::TAG_FIREWALL, 'Arachne\\Security\\Authentication\\FirewallInterface');
         $extension->add(self::TAG_AUTHORIZATOR, 'Arachne\\Security\\Authorization\\AuthorizatorInterface');
     } elseif ($extension = $this->getExtension('Arachne\\DIHelpers\\DI\\DIHelpersExtension', false)) {
         $extension->addResolver(self::TAG_FIREWALL, 'Arachne\\Security\\Authentication\\FirewallInterface');
         $extension->addResolver(self::TAG_AUTHORIZATOR, 'Arachne\\Security\\Authorization\\AuthorizatorInterface');
     } else {
         throw new AssertionException('Cannot add resolvers because arachne/di-helpers is not properly installed.');
     }
 }
开发者ID:arachne,项目名称:security,代码行数:26,代码来源:SecurityExtension.php

示例8: loadConfiguration

 public function loadConfiguration()
 {
     $config = $this->getConfig(self::$defaults);
     $this->classMappings = $config['targetEntityMappings'];
     $this->entitySources = $config['metadata'];
     foreach ($this->compiler->getExtensions() as $extension) {
         if ($extension instanceof IEntitySourceProvider) {
             $entitySource = $extension->getEntityFolderMappings();
             Validators::assert($entitySource, 'array');
             $this->entitySources = array_merge($this->entitySources, $entitySource);
         }
         if ($extension instanceof IClassMappingProvider) {
             $entityMapping = $extension->getClassnameToClassnameMapping();
             Validators::assert($entityMapping, 'array');
             $this->classMappings = array_merge($this->classMappings, $entityMapping);
         }
     }
     if ($config['sourceDir'] !== NULL) {
         $this->entitySources[] = $config['sourceDir'];
     }
     $builder = $this->getContainerBuilder();
     $name = $config['prefix'];
     $builder->addDefinition($name . ".resolver")->setClass('\\Doctrine\\ORM\\Tools\\ResolveTargetEntityListener');
     $builder->addDefinition($name . ".naming")->setClass('\\Doctrine\\ORM\\Mapping\\UnderscoreNamingStrategy');
     $builder->addDefinition($name . ".config")->setClass('\\Doctrine\\ORM\\Configuration')->addSetup(new Statement('setFilterSchemaAssetsExpression', [$config['dbal']['schema_filter']]));
     $builder->addDefinition($name . ".connection")->setClass('\\Doctrine\\DBAL\\Connection')->setFactory('@' . $name . '.entityManager::getConnection');
     $builder->addDefinition($name . ".entityManager")->setClass('\\Doctrine\\ORM\\EntityManager')->setFactory('\\Doctrine\\ORM\\EntityManager::create', [$config['connection'], '@' . $name . '.config', '@Doctrine\\Common\\EventManager']);
     if ($this->hasIBarPanelInterface()) {
         $builder->addDefinition($this->prefix($name . '.diagnosticsPanel'))->setClass(self::DOCTRINE_SQL_PANEL_FQN);
     }
     $this->addHelpersToKdybyConsole($builder);
 }
开发者ID:dtforce,项目名称:nette-doctrine,代码行数:32,代码来源:DoctrineExtension.php

示例9: createSchema

 private function createSchema($name, $command)
 {
     $variables = $this->variables;
     $defaults = $this->variables;
     Validators::assert($command['variables'], 'array');
     Validators::assert($command['templates'], 'array');
     if (isset($command['defaults'])) {
         Validators::assert($command['defaults'], 'array');
         $defaults = array_merge($defaults, $command['defaults']);
     }
     foreach ($command['variables'] as $var) {
         $variables[$var] = null;
     }
     foreach ($defaults as $varName => $value) {
         $variables[$varName] = $value;
     }
     foreach ($command['templates'] as $templateVar => $template) {
         if (!file_exists($template)) {
             throw new InvalidArgumentException("Template file '{$template}' used in FileTemplate command '{$name}' not found.");
         }
         if (!array_key_exists($templateVar, $variables)) {
             throw new InvalidArgumentException("Missing variable '{$templateVar}' in FileTemplate command '{$name}'. Templates must be in 'FILE_NAME_VAR: path/to/template' notation.");
         }
     }
     return new Schema($variables, $command['templates']);
 }
开发者ID:Joseki,项目名称:FileTemplate,代码行数:26,代码来源:FileTemplateExtension.php

示例10: addMacro

 /**
  * @param  callable
  * @return void
  */
 public function addMacro($macro)
 {
     Nette\Utils\Validators::assert($macro, 'callable');
     $container = $this->getContainerBuilder();
     $container->getDefinition('nette.latte')->addSetup('?->onCompile[] = function ($engine) { ' . $macro . '($engine->getCompiler()); }', array('@self'));
     $container->getDefinition($this->prefix('latteFactory'))->addSetup('?->onCompile[] = function ($engine) { ' . $macro . '($engine->getCompiler()); }', array('@self'));
 }
开发者ID:Richmond77,项目名称:learning-nette,代码行数:11,代码来源:LatteExtension.php

示例11: loadConfiguration

 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     Validators::assert($config['appId'], 'string', 'Application ID');
     Validators::assert($config['appSecret'], 'string:32', 'Application secret');
     Validators::assert($config['fileUploadSupport'], 'bool', 'file upload support');
     Validators::assert($config['trustForwarded'], 'bool', 'trust forwarded');
     Validators::assert($config['clearAllWithLogout'], 'bool', 'clear the facebook session when user changes');
     Validators::assert($config['domains'], 'array', 'api domains');
     Validators::assert($config['permissions'], 'list', 'permissions scope');
     Validators::assert($config['canvasBaseUrl'], 'null|url', 'base url for canvas application');
     $configurator = $builder->addDefinition($this->prefix('config'))->setClass('Kdyby\\Facebook\\Configuration')->setArguments(array($config['appId'], $config['appSecret']))->addSetup('$verifyApiCalls', array($config['verifyApiCalls']))->addSetup('$fileUploadSupport', array($config['fileUploadSupport']))->addSetup('$trustForwarded', array($config['trustForwarded']))->addSetup('$permissions', array($config['permissions']))->addSetup('$canvasBaseUrl', array($config['canvasBaseUrl']))->addSetup('$graphVersion', array($config['graphVersion']))->setInject(FALSE);
     if ($config['domains']) {
         $configurator->addSetup('$service->domains = ? + $service->domains', array($config['domains']));
     }
     $builder->addDefinition($this->prefix('session'))->setClass('Kdyby\\Facebook\\SessionStorage')->setInject(FALSE);
     foreach ($config['curlOptions'] as $option => $value) {
         if (defined($option)) {
             unset($config['curlOptions'][$option]);
             $config['curlOptions'][constant($option)] = $value;
         }
     }
     $apiClient = $builder->addDefinition($this->prefix('apiClient'))->setFactory('Kdyby\\Facebook\\Api\\CurlClient')->setClass('Kdyby\\Facebook\\ApiClient')->addSetup('$service->curlOptions = ?;', array($config['curlOptions']))->setInject(FALSE);
     if ($config['debugger']) {
         $builder->addDefinition($this->prefix('panel'))->setClass('Kdyby\\Facebook\\Diagnostics\\Panel')->setInject(FALSE);
         $apiClient->addSetup($this->prefix('@panel') . '::register', array('@self'));
     }
     $builder->addDefinition($this->prefix('synchronizeUserFacebook'))->setClass('Kdyby\\Facebook\\SynchronizeUserFacebook')->addTag('run')->setAutowired(FALSE)->setInject(FALSE);
     $builder->addDefinition($this->prefix('client'))->setClass('Kdyby\\Facebook\\Facebook')->setInject(FALSE);
     if ($config['clearAllWithLogout']) {
         $builder->getDefinition('user')->addSetup('$sl = ?; ?->onLoggedOut[] = function () use ($sl) { $sl->getService(?)->syncFacebookSession(); }', array('@container', '@self', $this->prefix('synchronizeUserFacebook')));
     }
 }
开发者ID:h4kuna,项目名称:Facebook,代码行数:34,代码来源:FacebookExtension.php

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

示例13: loadConfiguration

 public function loadConfiguration()
 {
     $container = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     Validators::assert($config['migrationDir'], 'string', 'Migration location directory');
     Validators::assert($config['migrationPrefix'], 'string', 'Migration name prefix');
     Validators::assert($config['options'], 'array', 'Generated SQL options');
     if (!$config['logFile']) {
         $config['logFile'] = FileSystem::normalizePath(sprintf('%s/_schema.txt', $config['migrationDir']));
     }
     $container->addDefinition($this->prefix('repository'))->setClass('Joseki\\Migration\\Database\\Repository', [$config['migrationTable']]);
     $manager = $container->addDefinition($this->prefix('manager'))->setClass('Joseki\\Migration\\Manager', [$config['migrationDir'], $config['migrationPrefix']]);
     $container->addDefinition($this->prefix('command.schema'))->setClass('Joseki\\Migration\\Console\\Command\\Schema', [$config['logFile']])->addTag(self::TAG_JOSEKI_COMMAND)->addTag(self::TAG_KDYBY_COMMAND);
     $container->addDefinition($this->prefix('command.create'))->setClass('Joseki\\Migration\\Console\\Command\\Create')->addTag(self::TAG_JOSEKI_COMMAND)->addTag(self::TAG_KDYBY_COMMAND);
     $container->addDefinition($this->prefix('command.migrate'))->setClass('Joseki\\Migration\\Console\\Command\\Migrate')->addTag(self::TAG_JOSEKI_COMMAND)->addTag(self::TAG_KDYBY_COMMAND);
     $container->addDefinition($this->prefix('platform'))->setClass('Doctrine\\DBAL\\Platforms\\MySqlPlatform');
     $container->addDefinition($this->prefix('generator.lm'))->setClass('Joseki\\Migration\\Generator\\LeanMapperSchemaGenerator', [$config['options']]);
     foreach ($this->getFiles($config['migrationDir']) as $index => $class) {
         if (!($class = $this->resolveRealClassName($class))) {
             continue;
         }
         $name = $this->prefix('migration.' . $index);
         $container->addDefinition($name)->setClass($class)->setInject(false)->setAutowired(false);
         $manager->addSetup('add', ['@' . $name]);
     }
 }
开发者ID:joseki,项目名称:migration,代码行数:26,代码来源:MigrationExtension.php

示例14: loadConfiguration

 public function loadConfiguration()
 {
     $config = $this->getConfig($this->defaults);
     Validators::assert($config['precision'], 'int:0..');
     $builder = $this->getContainerBuilder();
     $builder->addDefinition($this->prefix('calculator'))->setClass(Calculator::class, array($config['precision']));
 }
开发者ID:rixxi,项目名称:calculator,代码行数:7,代码来源:CalculatorExtension.php

示例15: load

	/**
	 * Reads configuration from file.
	 * @param  string  file name
	 * @param  string  optional section to load
	 * @return array
	 */
	public function load($file, $section = NULL)
	{
		if (!is_file($file) || !is_readable($file)) {
			throw new Nette\FileNotFoundException("File '$file' is missing or is not readable.");
		}
		$this->dependencies[] = realpath($file);
		$data = $this->getAdapter($file)->load($file);

		if ($section) {
			if (isset($data[self::INCLUDES_KEY])) {
				throw new Nette\InvalidStateException("Section 'includes' must be placed under some top section in file '$file'.");
			}
			$data = $this->getSection($data, $section, $file);
		}

		// include child files
		$merged = array();
		if (isset($data[self::INCLUDES_KEY])) {
			Validators::assert($data[self::INCLUDES_KEY], 'list', "section 'includes' in file '$file'");
			foreach ($data[self::INCLUDES_KEY] as $include) {
				$merged = Helpers::merge($this->load(dirname($file) . '/' . $include), $merged);
			}
		}
		unset($data[self::INCLUDES_KEY]);

		return Helpers::merge($data, $merged);
	}
开发者ID:nakoukal,项目名称:fakturace,代码行数:33,代码来源:Loader.php


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