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


PHP OptionsResolver::resolve方法代码示例

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


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

示例1: consume

 /**
  * consume.
  *
  * @param array $options Parameters sent to the processor
  */
 public function consume(array $options = array())
 {
     if (null !== $this->logger) {
         $this->logger->debug(sprintf('Start consuming queue %s.', $this->messageProvider->getQueueName()));
     }
     $this->optionsResolver->setDefaults(array('poll_interval' => 50000));
     if ($this->processor instanceof ConfigurableInterface) {
         $this->processor->setDefaultOptions($this->optionsResolver);
     }
     $options = $this->optionsResolver->resolve($options);
     if ($this->processor instanceof InitializableInterface) {
         $this->processor->initialize($options);
     }
     while (true) {
         while (null !== ($message = $this->messageProvider->get())) {
             if (false === $this->processor->process($message, $options)) {
                 break 2;
             }
         }
         if ($this->processor instanceof SleepyInterface) {
             if (false === $this->processor->sleep($options)) {
                 break;
             }
         }
         usleep($options['poll_interval']);
     }
     if ($this->processor instanceof TerminableInterface) {
         $this->processor->terminate($options);
     }
 }
开发者ID:kyar,项目名称:swarrot,代码行数:35,代码来源:Consumer.php

示例2: addAttributeFilter

 /**
  * {@inheritdoc}
  */
 public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = [])
 {
     try {
         $options = $this->resolver->resolve($options);
     } catch (\Exception $e) {
         throw InvalidArgumentException::expectedFromPreviousException($e, $attribute->getCode(), 'filter', 'option');
     }
     $this->checkLocaleAndScope($attribute, $locale, $scope, 'option');
     $field = $options['field'];
     if (Operators::IS_EMPTY !== $operator) {
         $this->checkValue($field, $value);
     }
     $joinAlias = $this->getUniqueAlias('filter' . $attribute->getCode(), true);
     // prepare join value condition
     $optionAlias = $joinAlias . '.option';
     if (Operators::IS_EMPTY === $operator) {
         $this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope));
         $this->qb->andWhere($this->qb->expr()->isNull($optionAlias));
     } else {
         // inner join to value
         $condition = $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope);
         if (FieldFilterHelper::getProperty($field) === FieldFilterHelper::CODE_PROPERTY) {
             $value = $this->objectIdResolver->getIdsFromCodes('option', $value);
         }
         $condition .= ' AND ( ' . $this->qb->expr()->in($optionAlias, $value) . ' ) ';
         $this->qb->innerJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
     }
     return $this;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:32,代码来源:OptionFilter.php

示例3: resolve

 /**
  * @return array
  */
 public function resolve(array $options)
 {
     $this->resolver = $this->optionsResolverFactory->create();
     $this->setDefaults();
     $this->setNormalizers();
     return $this->resolver->resolve($options);
 }
开发者ID:nunodotferreira,项目名称:ApiGen,代码行数:10,代码来源:ThemeConfigOptionsResolver.php

示例4: create

 /**
  * {@inheritdoc}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var PromotionInterface $promotion */
     $promotion = $this->promotionFactory->createNew();
     $promotion->setCode($options['code']);
     $promotion->setName($options['name']);
     $promotion->setDescription($options['description']);
     $promotion->setCouponBased($options['coupon_based']);
     $promotion->setUsageLimit($options['usage_limit']);
     $promotion->setExclusive($options['exclusive']);
     $promotion->setPriority($options['priority']);
     if (isset($options['starts_at'])) {
         $promotion->setStartsAt(new \DateTime($options['starts_at']));
     }
     if (isset($options['ends_at'])) {
         $promotion->setEndsAt(new \DateTime($options['ends_at']));
     }
     foreach ($options['channels'] as $channel) {
         $promotion->addChannel($channel);
     }
     foreach ($options['rules'] as $rule) {
         /** @var PromotionRuleInterface $promotionRule */
         $promotionRule = $this->promotionRuleExampleFactory->create($rule);
         $promotion->addRule($promotionRule);
     }
     foreach ($options['actions'] as $action) {
         /** @var PromotionActionInterface $promotionAction */
         $promotionAction = $this->promotionActionExampleFactory->create($action);
         $promotion->addAction($promotionAction);
     }
     return $promotion;
 }
开发者ID:NeverResponse,项目名称:Sylius,代码行数:36,代码来源:PromotionExampleFactory.php

示例5: addAttributeFilter

 /**
  * {@inheritdoc}
  */
 public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = [])
 {
     try {
         $options = $this->resolver->resolve($options);
     } catch (\Exception $e) {
         throw InvalidArgumentException::expectedFromPreviousException($e, $attribute->getCode(), 'filter', 'string');
     }
     $this->checkLocaleAndScope($attribute, $locale, $scope, 'string');
     if (Operators::IS_EMPTY !== $operator && Operators::IS_NOT_EMPTY !== $operator) {
         $this->checkValue($options['field'], $value);
     }
     $joinAlias = $this->getUniqueAlias('filter' . $attribute->getCode());
     $backendField = sprintf('%s.%s', $joinAlias, $attribute->getBackendType());
     if (Operators::IS_EMPTY === $operator) {
         $this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope));
         $this->qb->andWhere($this->prepareCriteriaCondition($backendField, $operator, $value));
     } else {
         $condition = $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope);
         if (Operators::IS_NOT_EMPTY === $operator) {
             $condition .= sprintf('AND (%s AND %s)', $this->qb->expr()->isNotNull($backendField), $this->qb->expr()->neq($backendField, $this->qb->expr()->literal('')));
             $this->qb->innerJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
         } elseif (Operators::DOES_NOT_CONTAIN === $operator) {
             $whereCondition = $this->prepareCondition($backendField, $operator, $value) . ' OR ' . $this->prepareCondition($backendField, Operators::IS_NULL, null);
             $this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
             $this->qb->andWhere($whereCondition);
         } else {
             $condition .= ' AND ' . $this->prepareCondition($backendField, $operator, $value);
             $this->qb->innerJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
         }
     }
     return $this;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:35,代码来源:StringFilter.php

示例6: addAttributeFilter

 /**
  * {@inheritdoc}
  */
 public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = [])
 {
     try {
         $options = $this->resolver->resolve($options);
     } catch (\Exception $e) {
         throw InvalidArgumentException::expectedFromPreviousException($e, $attribute->getCode(), 'filter', 'options');
     }
     $this->checkLocaleAndScope($attribute, $locale, $scope, 'options');
     if ($operator != Operators::IS_EMPTY) {
         $this->checkValue($options['field'], $value);
     }
     $joinAlias = $this->getUniqueAlias('filter' . $attribute->getCode());
     $joinAliasOpt = $this->getUniqueAlias('filterO' . $attribute->getCode());
     $backendField = sprintf('%s.%s', $joinAliasOpt, 'id');
     if (Operators::IS_EMPTY === $operator) {
         $this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope));
         $this->qb->leftJoin($joinAlias . '.' . $attribute->getBackendType(), $joinAliasOpt)->andWhere($this->qb->expr()->isNull($backendField));
     } else {
         if (FieldFilterHelper::getProperty($options['field']) === FieldFilterHelper::CODE_PROPERTY) {
             $value = $this->objectIdResolver->getIdsFromCodes('option', $value);
         }
         $this->qb->innerJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope))->innerJoin($joinAlias . '.' . $attribute->getBackendType(), $joinAliasOpt, 'WITH', $this->qb->expr()->in($backendField, $value));
     }
     return $this;
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:28,代码来源:OptionsFilter.php

示例7: create

 /**
  * {@inheritdoc}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var ChannelInterface $channel */
     $channel = $this->channelFactory->createNamed($options['name']);
     $channel->setCode($options['code']);
     $channel->setHostname($options['hostname']);
     $channel->setEnabled($options['enabled']);
     $channel->setColor($options['color']);
     $channel->setTaxCalculationStrategy($options['tax_calculation_strategy']);
     $channel->setThemeName($options['theme_name']);
     $channel->setDefaultLocale($options['default_locale']);
     foreach ($options['locales'] as $locale) {
         $channel->addLocale($locale);
     }
     $channel->setDefaultCurrency($options['default_currency']);
     foreach ($options['currencies'] as $currency) {
         $channel->addCurrency($currency);
     }
     foreach ($options['payment_methods'] as $paymentMethod) {
         $channel->addPaymentMethod($paymentMethod);
     }
     foreach ($options['shipping_methods'] as $shippingMethod) {
         $channel->addShippingMethod($shippingMethod);
     }
     return $channel;
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:30,代码来源:ChannelExampleFactory.php

示例8: generateCommandDefinition

 /**
  * @param string $commandName
  * @param array $commandOptions
  *
  * @return Definition
  */
 private function generateCommandDefinition($commandName, array $commandOptions)
 {
     $commandOptions = $this->optionsResolver->resolve($commandOptions);
     $definition = new Definition('PhpZone\\Docker\\Console\\Command\\DockerComposeCommand');
     $definition->setArguments(array($commandName, $commandOptions, new Reference('phpzone.docker.script_builder.docker_compose')));
     $definition->addTag('command');
     return $definition;
 }
开发者ID:phpzone,项目名称:docker,代码行数:14,代码来源:DockerCompose.php

示例9: generateCommandDefinition

 /**
  * @param string $commandName
  * @param array $commandOptions
  *
  * @return Definition
  *
  * @throws MissingOptionsException
  * @throws InvalidOptionsException
  */
 private function generateCommandDefinition($commandName, array $commandOptions)
 {
     $resolvedCommandOptions = $this->optionsResolver->resolve($commandOptions);
     $definition = new Definition('PhpZone\\Shell\\Console\\Command\\BatchScriptCommand');
     $definition->setArguments(array($commandName, $resolvedCommandOptions));
     $definition->addTag('command');
     return $definition;
 }
开发者ID:phpzone,项目名称:shell,代码行数:17,代码来源:Shell.php

示例10: resolveFilters

 /**
  * {@inheritdoc}
  */
 public function resolveFilters(array $filters)
 {
     $result = array();
     foreach ($filters as $field => $filter) {
         $result[$field] = $this->filtersResolver->resolve($filter);
     }
     return $result;
 }
开发者ID:WedgeSama,项目名称:Listor,代码行数:11,代码来源:OptionsResolver.php

示例11: create

 /**
  * {@inheritdoc}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var PromotionRuleInterface $promotionRule */
     $promotionRule = $this->promotionRuleFactory->createNew();
     $promotionRule->setType($options['type']);
     $promotionRule->setConfiguration($options['configuration']);
     return $promotionRule;
 }
开发者ID:NeverResponse,项目名称:Sylius,代码行数:12,代码来源:PromotionRuleExampleFactory.php

示例12: generate

 /**
  * @param array $options
  *        string $code   code to print
  *        string $type   type of barcode
  *        string $format output format
  *        int    $width  Minimum width of a single bar in user units.
  *        int    $height Height of barcode in user units.
  *        string $color  Foreground color (in SVG format) for bar elements (background is transparent).
  *
  * @return mixed
  */
 public function generate($options = array())
 {
     $options = $this->resolver->resolve($options);
     if (Type::getDimension($options['type']) == '2D') {
         return call_user_func_array(array($this->dns2d, $this->formatFunctionMap[$options['format']]), array($options['code'], $options['type'], $options['width'], $options['height'], $options['color']));
     } else {
         return call_user_func_array(array($this->dns1d, $this->formatFunctionMap[$options['format']]), array($options['code'], $options['type'], $options['width'], $options['height'], $options['color']));
     }
 }
开发者ID:cibincasso,项目名称:barcode-bundle,代码行数:20,代码来源:Generator.php

示例13: create

 /**
  * {@inheritdoc}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var ProductAssociationTypeInterface $productAssociationType */
     $productAssociationType = $this->productAssociationTypeFactory->createNew();
     $productAssociationType->setName($options['name']);
     $productAssociationType->setCode($options['code']);
     return $productAssociationType;
 }
开发者ID:NeverResponse,项目名称:Sylius,代码行数:12,代码来源:ProductAssociationTypeExampleFactory.php

示例14: create

 /**
  * {@inheritdoc}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var CustomerGroupInterface $customerGroup */
     $customerGroup = $this->customerGroupFactory->createNew();
     $customerGroup->setCode($options['code']);
     $customerGroup->setName($options['name']);
     return $customerGroup;
 }
开发者ID:NeverResponse,项目名称:Sylius,代码行数:12,代码来源:CustomerGroupExampleFactory.php

示例15: create

 /**
  * {@inheritdoc}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var Route $route */
     $route = $this->routeFactory->createNew();
     $route->setName($options['name']);
     $route->setContent($options['content']);
     return $route;
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:12,代码来源:RouteExampleFactory.php


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