本文整理汇总了PHP中Symfony\Component\OptionsResolver\OptionsResolverInterface::setAllowedTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP OptionsResolverInterface::setAllowedTypes方法的具体用法?PHP OptionsResolverInterface::setAllowedTypes怎么用?PHP OptionsResolverInterface::setAllowedTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\OptionsResolver\OptionsResolverInterface
的用法示例。
在下文中一共展示了OptionsResolverInterface::setAllowedTypes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param EventDispatcherInterface $dispatcher
*/
public function __construct(EventDispatcherInterface $dispatcher)
{
$this->dispatcher = $dispatcher;
$this->specResolver = new OptionsResolver;
$this->specResolver->setDefaults(
array(
'on' => self::ALL,
'from' => self::ALL,
'to' => self::ALL,
'exclude_from' => array(),
'exclude_to' => array(),
)
);
$this->specResolver->setAllowedTypes(
array(
'on' => array('string', 'array'),
'from' => array('string', 'array'),
'to' => array('string', 'array'),
'exclude_from' => array('string', 'array'),
'exclude_to' => array('string', 'array'),
)
);
$toArrayNormalizer = function (Options $options, $value) {
return (array)$value;
};
$this->specResolver->setNormalizers(
array(
'on' => $toArrayNormalizer,
'from' => $toArrayNormalizer,
'to' => $toArrayNormalizer,
'exclude_to' => $toArrayNormalizer,
'exclude_from' => $toArrayNormalizer,
)
);
}
示例2: setDefaultSettings
/**
* {@inheritdoc}
*/
public function setDefaultSettings(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('groups' => false));
if (version_compare(Kernel::VERSION, '2.6', '<')) {
$resolver->setAllowedTypes(array('groups' => array('bool', 'array')));
} else {
$resolver->setAllowedTypes('groups', array('bool', 'array'));
}
}
示例3: setDefaultOptions
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setRequired(array('fields'));
$reflection = new \ReflectionMethod($resolver, 'setAllowedTypes');
if ($reflection->getNumberOfParameters() === 2) {
$resolver->setAllowedTypes('fields', 'array');
} else {
$resolver->setAllowedTypes(array('fields' => 'array'));
}
}
示例4: setDefaultOptions
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('label' => false, "container" => null, "field" => null));
$resolver->setRequired("resource");
$resolver->setRequired("area");
$resolver->setRequired("category");
$resolver->setAllowedTypes('resource', 'Bigfish\\Bundle\\ResourceBundle\\Entity\\Resource');
$resolver->setAllowedTypes('area', 'Bigfish\\Bundle\\PagekitBundle\\Entity\\Area');
$resolver->setAllowedTypes('category', 'Bigfish\\Bundle\\EavBundle\\Entity\\Category');
}
示例5: 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'));
}
示例6: 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));
}
示例7: 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']);
}
示例8: 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']]);
}
示例9: 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'));
}
示例10: setDefaultOptions
/**
* Sets the default options for this type.
*
* @param OptionsResolverInterface $resolver The resolver for the options.
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('action' => null, 'bundles' => array(), 'domains' => array(), 'locales' => array(), 'files' => array(), 'result' => array(), 'translation_domain' => 'DavamigoTranslatorBundle'));
$resolver->setRequired(array('action', 'step'));
$resolver->setAllowedTypes(array('action' => 'string', 'step' => 'int', 'bundles' => 'array', 'domains' => 'array', 'locales' => 'array', 'files' => 'array', 'result' => 'array'));
$resolver->setAllowedValues(array('step' => array(1, 2, 3)));
}
示例11: configureAttributes
/**
* {@inheritdoc}
*/
public function configureAttributes(OptionsResolverInterface $resolver)
{
$resolver->setRequired(['text']);
$resolver->setOptional(['class', 'name']);
$resolver->setDefaults(['name' => '']);
$resolver->setAllowedTypes(['text' => 'string', 'class' => 'string']);
}
示例12: configureAttributes
/**
* {@inheritdoc}
*/
public function configureAttributes(OptionsResolverInterface $resolver)
{
$resolver->setRequired(['name', 'label']);
$resolver->setOptional(['comment', 'comment', 'repeat_min', 'repeat_max', 'limit', 'error', 'rules', 'filters', 'dependencies', 'main_id', 'visibility_change', 'upload_url', 'session_name', 'session_id', 'file_types', 'file_types_description', 'delete_handler', 'load_handler', 'property_path', 'dependencies', 'filters', 'rules']);
$resolver->setDefaults(['repeat_min' => 0, 'repeat_max' => ElementInterface::INFINITE, 'limit' => 1000, 'session_name' => session_name(), 'session_id' => session_id(), 'file_types_description' => 'file_types_description', 'file_types' => ['jpg', 'jpeg', 'png', 'gif'], 'property_path' => null, 'dependencies' => [], 'filters' => [], 'rules' => []]);
$resolver->setAllowedTypes(['file_types_description' => 'string', 'file_types' => 'array']);
}
示例13: 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']);
}
示例14: setDefaultOptions
/**
* Sets the configuration for the options resolver
* @param OptionsResolverInterface $resolver
*/
protected function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setRequired(array('directory'));
$resolver->setDefaults(array('mode' => self::MODE_DIRECTORY_AS_CATEGORY, 'include' => array(), 'limit' => null));
$resolver->setAllowedValues(array('mode' => array(self::MODE_DOCUMENT_AS_CATEGORY, self::MODE_DIRECTORY_AS_CATEGORY)));
$resolver->setAllowedTypes(array('directory' => 'string', 'mode' => 'int', 'include' => 'array'));
}
示例15: 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' => 'Создать'));
}