本文整理汇总了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']);
}
示例2: configureAttributes
/**
* {@inheritdoc}
*/
public function configureAttributes(OptionsResolverInterface $resolver)
{
$resolver->setRequired(['text']);
$resolver->setOptional(['class', 'name']);
$resolver->setDefaults(['name' => '']);
$resolver->setAllowedTypes(['text' => 'string', 'class' => 'string']);
}
示例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']);
}
示例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' => 'Создать'));
}
示例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;
}));
}
示例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'));
}
示例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);
}));
}
示例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'));
}
示例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));
}
示例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);
}
示例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']);
}
示例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'));
}
示例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']]);
}
示例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);
}
示例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);
}