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


PHP Validators::assertField方法代码示例

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


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

示例1: actionDefault

 public function actionDefault()
 {
     $params = $this->request->getParameters();
     Nette\Utils\Validators::assertField($params, 'input', 'Symfony\\Component\\Console\\Input\\Input');
     Nette\Utils\Validators::assertField($params, 'output', 'Symfony\\Component\\Console\\Output\\OutputInterface');
     $this->sendResponse(new Kdyby\Console\CliResponse($this->console->run($params['input'], $params['output'])));
 }
开发者ID:pepakriz,项目名称:Console,代码行数:7,代码来源:CliPresenter.php

示例2: validateConfigTypes

 /**
  * @throws AssertionException
  */
 protected function validateConfigTypes(array $config)
 {
     Validators::assertField($config, 'isRecursive', 'bool');
     Validators::assertField($config, 'trait', 'type');
     Validators::assertField($config, 'userCallable', 'string');
     Validators::assertField($config, 'userEntity', 'null|string');
 }
开发者ID:darkphoenixff4,项目名称:DoctrineBehaviors,代码行数:10,代码来源:BlameableExtension.php

示例3: configureClient

 /**
  * @param array $config
  * @param string $tokenStorageDefinition
  * @param string|NULL $name
  * @return ServiceDefinition
  * @throws InvalidConfigException
  */
 private function configureClient(array $config, $tokenStorageDefinition, $name = NULL)
 {
     $name = $name !== NULL ? ".{$name}" : '';
     $builder = $this->getContainerBuilder();
     $message = 'parameter % in LogisticsExtension configuration';
     Validators::assertField($config, 'appId', 'string', $message);
     Validators::assertField($config, 'secret', 'string', $message);
     if (!$builder->parameters['debugMode']) {
         Validators::assertField($config, 'apiBaseUrl', 'url', $message);
         Validators::assertField($config, 'apiBaseUrl', 'pattern:https\\:\\/\\/.*', $message);
     }
     $consumerDefinition = $builder->addDefinition($this->prefix("consumer{$name}"))->setClass(Consumer::class, [$config['appId'], $config['secret']])->setAutowired(FALSE);
     if (!array_key_exists('requestFactory', $config)) {
         $requestFactoryDefinition = $builder->addDefinition($this->prefix("requestFactory{$name}"))->setClass(RequestFactory::class, [$config['apiBaseUrl']])->setAutowired(FALSE);
     } else {
         // touch reference to validate it
         if (!$builder->getServiceName($requestFactoryDefinition = $config['requestFactory'])) {
             throw new InvalidConfigException("Invalid reference to service implementing IRequestFactory given: {$config['requestFactory']}");
         }
     }
     $connectorDefinition = $builder->addDefinition($this->prefix("connector{$name}"))->setClass(Connector::class, [$consumerDefinition, $tokenStorageDefinition, $requestFactoryDefinition])->setAutowired(FALSE);
     $logisticsClientDefiniton = $builder->addDefinition($this->prefix("logisticsClient{$name}"))->setClass(LogisticsClient::class, [$connectorDefinition, $requestFactoryDefinition]);
     if ($name !== '') {
         $logisticsClientDefiniton->setAutowired(FALSE);
     }
     return $logisticsClientDefiniton;
 }
开发者ID:Achse,项目名称:cargo-client,代码行数:34,代码来源:LogisticsExtension.php

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

示例5: loadConfiguration

 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     Validators::assertField($config, 'merchantId', 'string');
     Validators::assertField($config, 'shopName', 'string');
     Validators::assertField($config, 'productionMode', 'bool');
     Validators::assertField($config, 'returnMethod', 'string|pattern:(GET|POST)');
     $envConfig = $config['productionMode'] ? $config['production'] : $config['sandbox'];
     if (is_string($envConfig['privateKey'])) {
         $envConfig['privateKey'] = ['path' => $envConfig['privateKey'], 'password' => NULL];
     }
     if (empty($envConfig['privateKey']['path']) || !file_exists($envConfig['privateKey']['path'])) {
         throw new InvalidConfigException('Private key for not provided.');
     }
     $builder->addDefinition($this->prefix('config'))->setClass('Kdyby\\CsobPaymentGateway\\Configuration', [$config['merchantId'], $config['shopName']])->addSetup('setUrl', [$envConfig['url']])->addSetup('setReturnUrl', [$config['returnUrl']])->addSetup('setReturnMethod', [$config['returnMethod']]);
     $builder->addDefinition($this->prefix('httpClient'))->setClass('Kdyby\\CsobPaymentGateway\\IHttpClient')->setFactory('Kdyby\\CsobPaymentGateway\\Http\\GuzzleClient')->setAutowired(FALSE);
     $builder->addDefinition($this->prefix('signature'))->setClass('Kdyby\\CsobPaymentGateway\\Message\\Signature', [new Statement('Kdyby\\CsobPaymentGateway\\Certificate\\PrivateKey', [$envConfig['privateKey']['path'], $envConfig['privateKey']['password']]), new Statement('Kdyby\\CsobPaymentGateway\\Certificate\\PublicKey', [$envConfig['publicKey']])])->setAutowired(FALSE);
     $client = $builder->addDefinition($this->prefix('client'))->setClass('Kdyby\\CsobPaymentGateway\\Client', [$this->prefix('@config'), $this->prefix('@signature'), $this->prefix('@httpClient')]);
     if ($config['logging']) {
         if (!is_bool($config['logging']) && class_exists('Kdyby\\Monolog\\Logger')) {
             $client->addSetup('setLogger', [new Statement('@Kdyby\\Monolog\\Logger::channel', [$config['logging']])]);
         } else {
             $client->addSetup('setLogger');
             // autowire
         }
     }
     $builder->addDefinition($this->prefix('control'))->setImplement('Kdyby\\CsobPaygateNette\\UI\\ICsobControlFactory')->setArguments([$this->prefix('@client')]);
 }
开发者ID:jiripudil,项目名称:CsobPaygateNette,代码行数:29,代码来源:CsobPaygateExtension.php

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

示例7: buildClient

 /**
  * @param string $name
  * @param array $config
  * @return Nette\DI\ServiceDefinition
  */
 protected function buildClient($name, $config)
 {
     $builder = $this->getContainerBuilder();
     $defaultConfig = $this->getConfig($this->clientDefaults);
     if ($parentName = Config\Helpers::takeParent($config)) {
         Nette\Utils\Validators::assertField($this->configuredClients, $parentName, 'array', "parent configuration '%', are you sure it's defined?");
         $defaultConfig = Config\Helpers::merge($this->configuredClients[$parentName], $defaultConfig);
     }
     $config = Config\Helpers::merge($config, $defaultConfig);
     $config = array_intersect_key(self::fixClientConfig($config), $this->clientDefaults);
     $client = $builder->addDefinition($clientName = $this->prefix(($name ? $name . '_' : '') . 'client'))->setClass('Kdyby\\Redis\\RedisClient', ['host' => $config['host'], 'port' => $config['port'], 'database' => $config['database'], 'timeout' => $config['timeout'], 'auth' => $config['auth'], 'persistent' => $config['persistent']]);
     if (empty($builder->parameters[$this->name]['defaultClient'])) {
         $builder->parameters[$this->name]['defaultClient'] = $clientName;
         $this->configuredClients['default'] = $config;
         $builder->addDefinition($this->prefix('default_client'))->setClass('Kdyby\\Redis\\RedisClient')->setFactory('@' . $clientName)->setAutowired(FALSE);
     } else {
         $client->setAutowired(FALSE);
     }
     $this->configuredClients[$name] = $config;
     $client->addSetup('setupLockDuration', [$config['lockDuration'], $config['lockAcquireTimeout']]);
     $client->addSetup('setConnectionAttempts', [$config['connectionAttempts']]);
     $client->addTag('redis.client');
     if (array_key_exists('debugger', $config) && $config['debugger']) {
         $builder->addDefinition($panelName = $clientName . '.panel')->setClass('Kdyby\\Redis\\Diagnostics\\Panel')->setFactory('Kdyby\\Redis\\Diagnostics\\Panel::register')->addSetup('$renderPanel', [$config['debugger'] !== self::PANEL_COUNT_MODE])->addSetup('$name', [$name ?: 'default']);
         $client->addSetup('setPanel', ['@' . $panelName]);
     }
     return $client;
 }
开发者ID:kdyby,项目名称:redis,代码行数:33,代码来源:RedisExtension.php

示例8: configValidation

 /**
  * @param $config
  * @return void
  */
 public function configValidation($config)
 {
     Validators::assertField($config, 'authenticators', 'array');
     Validators::assertField($config, 'ips', 'array');
     Validators::assertField($config, 'referers', 'array');
     Validators::assertField($config, 'cors', 'array');
     Validators::assertField($config, 'systemSalt', 'string');
 }
开发者ID:Budry,项目名称:TinyREST,代码行数:12,代码来源:RestExtension.php

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

示例10: getSection

 private function getSection(array $data, $key, $file)
 {
     Validators::assertField($data, $key, 'array|null', "section '%' in file '{$file}'");
     $item = $data[$key];
     if ($parent = Helpers::takeParent($item)) {
         $item = Helpers::merge($item, $this->getSection($data, $parent, $file));
     }
     return $item;
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:9,代码来源:Loader.php

示例11: loadConfiguration

 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->getConfig(array('enabled' => !$builder->expand('%debugMode%')));
     Nette\Utils\Validators::assertField($config, 'enabled');
     if ($builder->expand($config['enabled'])) {
         $builder->addDefinition($this->prefix('listener'))->setClass('Mishak\\NewRelicLogger\\NewRelicProfilingListener')->addTag(Kdyby\Events\DI\EventsExtension::SUBSCRIBER_TAG);
     }
 }
开发者ID:enumag,项目名称:newrelic-nette-1,代码行数:9,代码来源:NewRelicLoggerExtension.php

示例12: validateConfigTypes

 /**
  * @throws AssertionException
  */
 private function validateConfigTypes(array $config)
 {
     Validators::assertField($config, 'isRecursive', 'bool');
     Validators::assertField($config, 'currentLocaleCallable', NULL | 'array');
     Validators::assertField($config, 'translatableTrait', 'type');
     Validators::assertField($config, 'translationTrait', 'type');
     Validators::assertField($config, 'translatableFetchMode', 'string');
     Validators::assertField($config, 'translationFetchMode', 'string');
 }
开发者ID:kastanekdavid,项目名称:DoctrineBehaviors,代码行数:12,代码来源:TranslatableExtension.php

示例13: loadConfiguration

 /**
  * Creates service definitions according annotated services classes.
  */
 public function loadConfiguration()
 {
     $this->conf = $this->getConfig($this->defaults);
     Validators::assertField($this->conf, 'dirs', 'array');
     Validators::assertField($this->conf, 'allowedAnnotations', 'array');
     //Browse the directory and subdirectories and search services
     foreach ($this->conf['dirs'] as $dir) {
         $this->addServicesFromDir($dir);
     }
 }
开发者ID:mike227,项目名称:n-service-annotations,代码行数:13,代码来源:Extension.php

示例14: loadConfiguration

 public function loadConfiguration()
 {
     $config = $this->validateConfig($this->defaults);
     $builder = $this->getContainerBuilder();
     Validators::assertField($config, 'goId', 'string|number');
     Validators::assertField($config, 'clientId', 'string|number');
     Validators::assertField($config, 'clientSecret', 'string');
     Validators::assertField($config, 'test', 'bool');
     $builder->addDefinition($this->prefix('client'))->setClass(Client::class, [new Statement(Config::class, [$config['goId'], $config['clientId'], $config['clientSecret'], $config['test'] !== FALSE ? Config::TEST : Config::PROD])]);
 }
开发者ID:markette,项目名称:gopay-inline,代码行数:10,代码来源:GopayExtension.php

示例15: loadConfiguration

 public function loadConfiguration()
 {
     $this->defaults = Nette\Neon\Neon::decode(file_get_contents(__DIR__ . '/defaults.neon'))['hyperrow'];
     $config = $this->getConfig($this->defaults);
     Validators::assertField($config, 'nestedTransactions', 'bool');
     $builder = $this->getContainerBuilder();
     $builder->addDefinition($this->prefix('config'))->setClass(Config::class, [$config]);
     $builder->addDefinition($this->prefix('factory'))->setClass(Factory::class, [$config['classes']['selection']['mapping'], $config['classes']['row']['mapping']]);
     $builder->addDefinition($this->prefix('generator'))->setClass(Generator::class, [$config])->setAutowired(FALSE);
 }
开发者ID:filsedla,项目名称:hyperrow,代码行数:10,代码来源:Extension.php


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