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


PHP OptionsResolverInterface::setOptional方法代码示例

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


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

示例1: __construct

 /**
  * Instanciate the base filter
  *
  * @param AttributeValidatorHelper       $attrValidatorHelper
  * @param ConfigurationRegistryInterface $registry
  * @param ReferenceDataIdResolver        $idsResolver
  * @param array                          $supportedOperators
  */
 public function __construct(AttributeValidatorHelper $attrValidatorHelper, ConfigurationRegistryInterface $registry, ReferenceDataIdResolver $idsResolver, array $supportedOperators = [])
 {
     $this->attrValidatorHelper = $attrValidatorHelper;
     $this->registry = $registry;
     $this->idsResolver = $idsResolver;
     $this->supportedOperators = $supportedOperators;
     $this->optionsResolver = new OptionsResolver();
     $this->optionsResolver->setRequired(['field']);
     $this->optionsResolver->setOptional(['locale', 'scope']);
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:18,代码来源:ReferenceDataFilter.php

示例2: configureAttributes

 /**
  * {@inheritdoc}
  */
 public function configureAttributes(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['text']);
     $resolver->setOptional(['class', 'name']);
     $resolver->setDefaults(['name' => '']);
     $resolver->setAllowedTypes(['text' => 'string', 'class' => 'string']);
 }
开发者ID:jmarceli,项目名称:WellCommerce,代码行数:10,代码来源:StaticText.php

示例3: configureAttributes

 /**
  * Configures Form attributes
  *
  * @param OptionsResolverInterface $resolver
  */
 public function configureAttributes(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['name']);
     $resolver->setOptional(['class', 'action', 'method', 'tabs', 'property_path', 'dependencies', 'property_path', 'dependencies', 'filters', 'rules']);
     $resolver->setDefaults(['action' => '', 'class' => '', 'method' => self::FORM_METHOD, 'tabs' => self::TABS_VERTICAL, 'property_path' => null, 'dependencies' => [], 'filters' => [], 'rules' => []]);
     $resolver->setAllowedTypes(['class' => 'string', 'action' => 'string', 'method' => 'string', 'tabs' => 'integer']);
 }
开发者ID:jmarceli,项目名称:WellCommerce,代码行数:12,代码来源:Form.php

示例4: setDefaultOptions

 /**
  * @param OptionsResolverInterface $resolver
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setOptional(array('default', 'query_builder', 'choices'));
     $resolver->setAllowedTypes(array('choices' => 'array'));
     $resolver->setRequired(array('create_form_type', 'class', 'property'));
     $resolver->setDefaults(array('multiple' => false, 'to_select_text' => 'Выбрать', 'to_new_text' => 'Создать'));
 }
开发者ID:amaxlab,项目名称:form-bundle,代码行数:10,代码来源:SelectOrAddType.php

示例5: setDefaultOptions

 /**
  * Custom options:
  * - "workflow_item" - required, instance of WorkflowItem entity
  * - "step_name"     - optional, name of step
  *
  * @param OptionsResolverInterface $resolver
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(array('workflow_item'));
     $resolver->setOptional(array('step_name'));
     $resolver->setAllowedTypes(array('step_name' => 'string'));
     $resolver->setNormalizers(array('step_name' => function (Options $options, $stepName) {
         /** @var Workflow $workflow */
         $workflow = $options['workflow'];
         /** @var WorkflowItem $workflowItem */
         $workflowItem = $options['workflow_item'];
         if (!$stepName) {
             $stepName = $workflowItem->getCurrentStepName();
         }
         if (!$workflow->getStepManager()->getStep($stepName)) {
             throw new InvalidConfigurationException(sprintf('Invalid reference to unknown step "%s" of workflow "%s".', $stepName, $workflow->getName()));
         }
         return $stepName;
     }, 'disable_attribute_fields' => function (Options $options, $disableAttributeFields) {
         /** @var Workflow $workflow */
         $workflow = $options['workflow'];
         /** @var WorkflowItem $workflowItem */
         $workflowItem = $options['workflow_item'];
         $step = $workflow->getStepManager()->getStep($options['step_name']);
         if ($step->getName() !== $workflowItem->getCurrentStepName() || $workflowItem->isClosed()) {
             $disableAttributeFields = true;
         }
         return $disableAttributeFields;
     }));
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:36,代码来源:WorkflowStepType.php

示例6: setDefaultOptions

 /**
  * Sets the configuration for the options resolver
  * @param OptionsResolverInterface $resolver
  */
 protected function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(array('file', 'document_columns', 'category_column'));
     $resolver->setOptional(array('limit', 'delimiter', 'enclosure', 'escape', 'category_modifier'));
     $resolver->setDefaults(array('limit' => false, 'length' => 0, 'delimiter' => ',', 'enclosure' => '"', 'escape' => '\\', 'category_modifier' => false));
     $resolver->setAllowedTypes(array('file' => 'string', 'document_columns' => 'array', 'category_column' => 'string', 'length' => 'int', 'delimiter' => 'string', 'enclosure' => 'string', 'escape' => 'string'));
 }
开发者ID:camspiers,项目名称:statistical-classifier,代码行数:11,代码来源:CSV.php

示例7: setDefaultOptions

 /**
  * {@inheritDoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $uploadConfig = array('uploadRoute' => 'comur_api_upload', 'uploadUrl' => null, 'webDir' => null, 'fileExt' => '*.jpg;*.gif;*.png;*.jpeg', 'libraryDir' => null, 'libraryRoute' => 'comur_api_image_library', 'showLibrary' => true, 'saveOriginal' => false);
     $cropConfig = array('minWidth' => 1, 'minHeight' => 1, 'aspectRatio' => true, 'cropRoute' => 'comur_api_crop', 'forceResize' => true, 'thumbs' => null);
     $resolver->setDefaults(array('uploadConfig' => $uploadConfig, 'cropConfig' => $cropConfig, 'inherit_data' => true, 'help' => null, 'show_fade' => false));
     $resolver->setOptional(array('help', 'show_fade', 'image_checker', 'image_path'));
     $isGallery = $this->isGallery;
     $galleryDir = $this->galleryDir;
     $resolver->setNormalizers(array('uploadConfig' => function (Options $options, $value) use($uploadConfig, $isGallery, $galleryDir) {
         $config = array_merge($uploadConfig, $value);
         if ($isGallery) {
             $config['uploadUrl'] = $config['uploadUrl'] . '/' . $galleryDir;
             $config['webDir'] = $config['webDir'] . '/' . $galleryDir;
             $config['saveOriginal'] = false;
         }
         if (!isset($config['libraryDir'])) {
             $config['libraryDir'] = $config['uploadUrl'];
         }
         // if($config['saveOriginal']){
         //     $options['compound']=true;
         // }
         return $config;
     }, 'cropConfig' => function (Options $options, $value) use($cropConfig) {
         return array_merge($cropConfig, $value);
     }));
 }
开发者ID:HolyJo,项目名称:ComurImageBundle,代码行数:29,代码来源:CroppableImageType.php

示例8: setDefaultOptions

 protected function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('unicode' => true, 'milliseconds' => 200, 'symbol-size' => 'square-auto', 'process-timeout' => 600, 'command' => 'dmtxread'));
     $resolver->setOptional(array('newline', 'unicode', 'milliseconds', 'codewords', 'minimum-edge', 'maximum-edge', 'gap', 'page', 'square-deviation', 'resolution', 'symbol-size', 'threshold', 'x-range-min', 'x-range-max', 'y-range-min', 'y-range-max', 'corrections-max', 'diagnose', 'mosaic', 'stop-after', 'page-numbers', 'corners', 'shrink'));
     $resolver->setAllowedValues(array('symbol-size' => array('square-auto', 'rectangle-auto', '10x10', '24x24', '64x64')));
     $resolver->setAllowedTypes(array('newline' => 'bool', 'unicode' => 'bool', 'milliseconds' => 'integer', 'codewords' => 'bool', 'minimum-edge' => 'integer', 'maximum-edge' => 'integer', 'gap' => 'integer', 'page' => 'integer', 'square-deviation' => 'integer', 'resolution' => 'integer', 'threshold' => 'integer', 'corrections-max' => 'integer', 'diagnose' => 'bool', 'mosaic' => 'bool', 'stop-after' => 'integer', 'page-numbers' => 'bool', 'corners' => 'bool', 'shrink' => 'integer'));
 }
开发者ID:pmaselkowski,项目名称:php-dmtx,代码行数:7,代码来源:Reader.php

示例9: configureResolver

 /**
  * {@inheritdoc}
  */
 public function configureResolver(OptionsResolverInterface $resolver)
 {
     $patientNormalizer = function (Options $options, $value) {
         static $resource;
         if (!$resource) {
             $resource = $options['patient_resource']->getRepository();
         }
         return $resource->getByMRN($value);
     };
     $codes = $this->getCodes();
     $diagnosisNormalizer = function (Options $options, $value) use($codes) {
         static $resource;
         if (!$resource) {
             $resource = $options['diagnosis_resource']->getRepository();
         }
         if ($patient = $options['patient']) {
             foreach ($patient->getDiagnoses() as $diagnosis) {
                 if (in_array($diagnosis->getCode()->getCode(), $codes)) {
                     return $diagnosis;
                 }
             }
         }
     };
     $dateNormalizer = function (Options $options, $value) {
         return empty($value) ? null : new DateTime($value);
     };
     $resolver->setRequired(array('patient', 'activity_date'));
     $resolver->setOptional(array('diagnosis'));
     $resolver->setAllowedTypes(array('patient' => array('string'), 'diagnosis' => array('Accard\\Component\\Diagnosis\\Model\\DiagnosisInterface', 'null'), 'activity_date' => array('string', 'null')));
     $resolver->setNormalizers(array('patient' => $patientNormalizer, 'diagnosis' => $diagnosisNormalizer, 'activity_date' => $dateNormalizer));
 }
开发者ID:upenn-dag,项目名称:patient-repository,代码行数:34,代码来源:ActivityImporter.php

示例10: array

 function it_should_define_assigned_data_class(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('data_class' => 'Rule', 'validation_groups' => array('sylius')))->shouldBeCalled();
     $resolver->setOptional(array('configuration_type'))->shouldBeCalled();
     $resolver->setDefaults(array('configuration_type' => RuleInterface::TYPE_ITEM_TOTAL))->shouldBeCalled();
     $this->setDefaultOptions($resolver);
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:7,代码来源:RuleTypeSpec.php

示例11: configureAttributes

 /**
  * {@inheritdoc}
  */
 public function configureAttributes(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['name']);
     $resolver->setOptional(['label', 'class', 'repeat_min', 'repeat_max', 'property_path', 'dependencies', 'filters', 'rules']);
     $resolver->setDefaults(['property_path' => null, 'dependencies' => [], 'filters' => [], 'rules' => []]);
     $resolver->setAllowedTypes(['name' => ['int', 'string'], 'label' => 'string', 'class' => 'string', 'repeat_min' => ['int', 'string'], 'repeat_max' => ['int', 'string'], 'dependencies' => 'array']);
 }
开发者ID:jmarceli,项目名称:WellCommerce,代码行数:10,代码来源:Fieldset.php

示例12: setDefaultOptions

 protected function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('encoding' => 'ascii', 'module' => 5, 'symbol-size' => 'square-auto', 'format' => 'png', 'message-separator' => ' ', 'process-timeout' => 600, 'command' => 'dmtxwrite'));
     $resolver->setOptional(array('resolution', 'margin'));
     $resolver->setAllowedValues(array('encoding' => array('best', 'fast', 'ascii', 'c40', 'text', 'x12', 'edifact', '8base256'), 'format' => array('png', 'tif', 'gif', 'pdf'), 'symbol-size' => array('square-auto', 'rectangle-auto', '10x10', '24x24', '64x64')));
     $resolver->setAllowedTypes(array('resolution' => 'integer', 'module' => 'integer', 'margin' => 'integer'));
 }
开发者ID:pmaselkowski,项目名称:php-dmtx,代码行数:7,代码来源:Writer.php

示例13: configureAttributes

 /**
  * {@inheritdoc}
  */
 public function configureAttributes(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['name', 'label', 'prefixes']);
     $resolver->setDefaults(['prefixes' => ['net', 'gross']]);
     $resolver->setOptional(['vat_field', 'comment', 'suffix', 'prefix', 'selector', 'wrap', 'class', 'css_attribute', 'max_length', 'error', 'rules', 'filters', 'dependencies', 'default']);
     $resolver->setAllowedTypes(['name' => 'string', 'label' => 'string', 'comment' => 'string', 'suffix' => 'string', 'prefix' => 'string', 'selector' => 'string', 'wrap' => 'string', 'class' => 'string', 'css_attribute' => 'string', 'max_length' => 'integer', 'error' => 'string', 'filters' => 'array', 'rules' => 'array', 'dependencies' => 'array', 'default' => ['string', 'integer']]);
 }
开发者ID:jmarceli,项目名称:WellCommerce,代码行数:10,代码来源:Price.php

示例14: array

 function it_should_configure_the_resolver(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('format' => Argument::any(), 'language' => \Locale::getDefault(), 'leading_zero' => false))->shouldBeCalled();
     $resolver->setOptional(array('placeholder', 'language', 'leading_zero'))->shouldBeCalled();
     $resolver->setAllowedTypes(array('placeholder' => array('string'), 'language' => array('string'), 'leading_zero' => array('bool')))->shouldBeCalled();
     $this->setDefaultOptions($resolver);
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:7,代码来源:DateExtensionSpec.php

示例15: array

 function it_should_define_assigned_data_class(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('data_class' => 'Action', 'validation_groups' => array('sylius')))->shouldBeCalled();
     $resolver->setOptional(array('configuration_type'))->shouldBeCalled();
     $resolver->setDefaults(array('configuration_type' => ActionInterface::TYPE_FIXED_DISCOUNT))->shouldBeCalled();
     $this->setDefaultOptions($resolver);
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:7,代码来源:ActionTypeSpec.php


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