Example #1
0
 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'];
     }
 }
 /**
  * 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);
 }