當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。