本文整理汇总了PHP中Symfony\Component\OptionsResolver\OptionsResolverInterface类的典型用法代码示例。如果您正苦于以下问题:PHP OptionsResolverInterface类的具体用法?PHP OptionsResolverInterface怎么用?PHP OptionsResolverInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OptionsResolverInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaultOptions
/**
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('data_class' => 'Bruvinsky\\HighschoolBundle\\Entity\\Subject'));
// $params = [
// 'class' => 'Bruvinsky\HighschoolBundle\Entity\Subject',
// 'compound' => true,
// 'multiple' => true,
// 'expanded' => true,
// 'property' => 'name',
// ];
// if (!empty($this->choiceList['documentList'])) {
// // this is used in form "show" mode
// $params['choices'] = $this->choiceList;
// } elseif (!empty($this->choiceList['idList'])) {
// // this is used on the form validation
// $idList = $this->choiceList['idList'];
// $params['query_builder'] = function ($repo) use ($idList) {
// return $repo->createQueryBuilder()
// ->field('id')->in($idList);
// };
// } else {
// #$params['choices'] = [];
// }
// $resolver->setDefaults($params);
}
示例2: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$defaultFieldOptions = ['multiple' => true];
$resolver->setDefaults(['dictionary_code' => null, 'class' => null, 'field_options' => $defaultFieldOptions]);
$resolver->setNormalizers(['class' => function (Options $options, $value) {
if ($value !== null) {
return $value;
}
if (empty($options['dictionary_code'])) {
throw new InvalidOptionsException('Either "class" or "dictionary_code" must option must be set.');
}
$class = ExtendHelper::buildEnumValueClassName($options['dictionary_code']);
if (!is_a($class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue', true)) {
throw new InvalidOptionsException(sprintf('"%s" must be a child of "%s"', $class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue'));
}
return $class;
}, 'field_options' => function (Options $options, $value) use(&$defaultFieldOptions) {
if (isset($options['class'])) {
$nullValue = null;
if ($options->has('null_value')) {
$nullValue = $options->get('null_value');
}
$value['choices'] = $this->getChoices($options['class'], $nullValue);
} else {
$value['choices'] = [];
}
return array_merge($defaultFieldOptions, $value);
}]);
}
示例3: 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);
}
示例4: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$emptyData = function (FormInterface $form, $clientData) {
return $clientData;
};
$resolver->setDefaults(array('value' => '1', 'empty_data' => $emptyData, 'compound' => false));
}
示例5: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('data_class' => 'Barbon\\HostedApi\\AppBundle\\Form\\Common\\Model\\BankAccount', 'validation_groups' => function (FormInterface $form) {
$validationGroup = new BankAccountValidationGroupSelector();
return $validationGroup->chooseGroups($form);
}));
}
示例6: configureAttributes
/**
* {@inheritdoc}
*/
public function configureAttributes(OptionsResolverInterface $resolver)
{
$resolver->setRequired(['name', 'label']);
$resolver->setOptional(['rows', 'comment', 'suffix', 'prefix', 'selector', 'wrap', 'class', 'css_attribute', 'max_length', 'error', 'rules', 'filters', 'dependencies', 'default', 'property_path', 'transformer']);
$resolver->setDefaults(['dependencies' => [], 'filters' => [], 'rules' => [], 'transformer' => null, 'property_path' => null]);
$resolver->setAllowedTypes(['name' => 'string', 'rows' => 'int', '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']]);
}
示例7: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$class = get_class($this);
$class = substr($class, strlen('Kaikmedia\\GalleryModule\\Form\\Features\\'));
$class = substr($class, 0, -strlen('Type'));
$resolver->setDefaults(['data_class' => 'Kaikmedia\\GalleryModule\\Features\\' . $class]);
}
示例8: setDefaultOptions
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$compound = function (Options $options) {
return isset($options['parent']) ? $options['parent'] : 'hidden';
};
$resolver->setDefaults(array('compound' => $compound, 'model_manager' => null, 'class' => null));
}
示例9: run
/**
* {@inheritdoc}
*/
public function run(OptionsResolverInterface $resolver)
{
$records = array();
$localRecords = $this->localSource->execute();
$results = $this->ridicSource->execute();
foreach ($results as $key => $result) {
$result = array_change_key_case($result, CASE_LOWER);
$mrn = $result['hup_mrn'];
try {
$result['previous_record'] = $this->provider->getPatientByMRN($mrn);
} catch (PatientNotFoundException $e) {
unset($result, $results[$key]);
continue;
}
$result['identifier'] = $result['course_ser'];
$result['patient'] = $result['hup_mrn'];
$result['activity_date'] = $result['first_treatment_dt'];
$result['import_description'] = sprintf('%s ridic dose on the %s.', $result['course_ser'], $result['hup_mrn']);
$record = $resolver->resolve($result);
if ($record['patient'] && !in_array($record['course_ser'], $localRecords)) {
$records[] = $record;
}
unset($results[$key]);
}
return $records;
}
示例10: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('class' => $this->dataClass, 'property' => 'canonical', 'label' => 'accard.diagnosis.entity_name', 'query_builder' => function (EntityRepository $er) {
static $qb;
return $qb = $er->getQueryBuilder();
}, 'empty_value' => 'accard.diagnosis.form.select_diagnosis'));
}
示例11: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolverInterface $resolver)
{
$resolver->setRequired(['rows_per_page', 'key']);
$resolver->setOptional(['default_sorting', 'right_click_menu', 'auto_suggest_delay', 'auto_suggest_min_length', 'auto_suggest_suggestions', 'only_one_selected', 'no_column_modification', 'no_column_resizing', 'create_input', 'save_column_modification', 'persistent']);
$resolver->setDefaults(['rows_per_page' => 50, 'key' => 'id']);
$resolver->setAllowedTypes(['rows_per_page' => 'int', 'key' => ['int', 'string'], 'default_sorting' => ['int', 'string'], 'right_click_menu' => 'bool', 'auto_suggest_delay' => 'int', 'auto_suggest_min_length' => 'int', 'auto_suggest_suggestions' => 'int', 'only_one_selected' => 'bool', 'no_column_modification' => 'bool', 'no_column_resizing' => 'bool', 'create_input' => 'bool', 'save_column_modification' => 'bool', 'persistent' => 'bool']);
}
示例12: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
if (!$this->channelClass) {
throw new \InvalidArgumentException('Channel class is missing');
}
$queryBuilderNormalizer = function (Options $options, $qb) {
/** @var EntityManager $em */
$em = $options['em'];
/** @var EntityRepository $repository */
$repository = $em->getRepository($this->channelClass);
$entities = $options->get('entities');
/** @var QueryBuilder $queryBuilder */
$queryBuilder = $qb($repository, $entities);
$queryBuilder->join('c.dataSource', 'd')->andWhere($queryBuilder->expr()->andX($queryBuilder->expr()->eq('d.type', ':type'), $queryBuilder->expr()->eq('d.enabled', ':enabled')))->setParameter('type', ChannelType::TYPE)->setParameter('enabled', true);
$filteredQb = clone $queryBuilder;
/** @var Channel[] $channels */
$channels = $filteredQb->getQuery()->getResult();
$skipEntities = [];
foreach ($channels as $channel) {
$dataSource = $channel->getDataSource();
if (!(bool) $dataSource->getSynchronizationSettings()->offsetGetOr('isTwoWaySyncEnabled')) {
$skipEntities[] = $channel->getId();
}
}
if ($skipEntities) {
$queryBuilder->andWhere($queryBuilder->expr()->notIn('c.id', ':skipEntities'))->setParameter('skipEntities', $skipEntities);
}
return $queryBuilder;
};
$resolver->setNormalizers(['query_builder' => $queryBuilderNormalizer]);
}
示例13: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('em' => null, 'property' => null, 'queryBuilder' => null, 'multiple' => true, 'values_delimiter' => ','))->setAllowedValues(array('multiple' => array(true, false)));
$resolver->setRequired(array('class'));
$registry = $this->registry;
$emNormalizer = function (Options $options, $em) use($registry) {
if (null !== $em) {
if ($em instanceof EntityManager) {
return $em;
} elseif (is_string($em)) {
$em = $registry->getManager($em);
} else {
throw new FormException(sprintf('Option "em" should be a string or entity manager object, %s given', is_object($em) ? get_class($em) : gettype($em)));
}
} else {
$em = $registry->getManagerForClass($options['class']);
}
if (null === $em) {
throw new FormException(sprintf('Class "%s" is not a managed Doctrine entity. Did you forget to map it?', $options['class']));
}
return $em;
};
$queryBuilderNormalizer = function (Options $options, $queryBuilder) {
if (null !== $queryBuilder && !is_callable($queryBuilder)) {
throw new FormException(sprintf('Option "queryBuilder" should be a callable, %s given', is_object($queryBuilder) ? get_class($queryBuilder) : gettype($queryBuilder)));
}
return $queryBuilder;
};
$resolver->setNormalizers(array('em' => $emNormalizer, 'queryBuilder' => $queryBuilderNormalizer));
}
示例14: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(['multiple' => true, 'expanded' => true, 'choices' => $this->getChoices()]);
$resolver->setNormalizers(['disabled' => function (Options $options, $value) {
return $this->isReadOnly($options) ? true : $value;
}]);
}
示例15: setOptions
/**
* {@inheritDoc}
*/
public function setOptions(OptionsResolverInterface $resolver)
{
$resolver->setRequired(['forced', 'origin', 'feed', 'date_locale', 'number_locale', 'default_values']);
$resolver->setAllowedValues(['date_locale' => ['en', 'nl'], 'number_locale' => ['en', 'nl']]);
$resolver->setAllowedTypes(['forced' => 'bool', 'origin' => 'FM\\IoBundle\\Model\\OriginInterface', 'feed' => 'FM\\IoBundle\\Entity\\Feed', 'default_values' => 'array']);
$resolver->setDefaults(['forced' => false, 'date_locale' => 'en', 'number_locale' => 'en', 'default_values' => []]);
}