本文整理汇总了PHP中Symfony\Component\Form\FormBuilder::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::getType方法的具体用法?PHP FormBuilder::getType怎么用?PHP FormBuilder::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkFormBuilderDeps
private function checkFormBuilderDeps(\Symfony\Component\Form\FormBuilder $builder, array &$elements, array &$requirments)
{
if ($builder->getCompound()) {
$type = $builder->getType();
if ($type instanceof \Symfony\Component\Form\Extension\DataCollector\Proxy\ResolvedTypeDataCollectorProxy) {
$type = $type->getInnerType();
}
if (!$type instanceof \Symfony\Component\Form\Extension\Core\Type\ChoiceType) {
foreach ($builder->all() as $child) {
$this->checkFormBuilderDeps($child, $elements, $requirments);
}
}
}
$options = $builder->getOptions();
if (isset($options['sf_form_dynamic'])) {
foreach ($options['sf_form_dynamic'] as $and) {
foreach ($and as $_name => $values) {
$requirments[$_name] = true;
}
}
$elements[$builder->getName()] = $options['sf_form_dynamic'];
}
}
示例2: getValue
/**
* Get type value from resource.
*
* @param $objectOrArray
* @param $propertyPath
* @param FormBuilder $formConfig
*
* @return array|string
*/
public function getValue($objectOrArray, $propertyPath, FormBuilder $formConfig)
{
if (!is_a($objectOrArray, 'EasyRdf\\Resource')) {
return $objectOrArray;
}
if (is_string($propertyPath)) {
$propertyPath = new PropertyPath($propertyPath);
} elseif (!$propertyPath instanceof PropertyPathInterface) {
throw new UnexpectedTypeException($propertyPath, 'string or Symfony\\Component\\PropertyAccess\\PropertyPathInterface');
}
$property = (string) $propertyPath;
$resources = null;
if ($formConfig->getOption('multiple')) {
$resources = $objectOrArray->all($property);
} elseif ($formConfig->getType()->getName() === 'collection') {
$resources = $objectOrArray->all($property);
} else {
$resources = $objectOrArray->get($property);
}
return $this->getLiteralValues($resources);
}