setFieldDefinition() public method

public setFieldDefinition ( Field $field )
$field Jarves\Configuration\Field
Example #1
0
 /**
  * @return \Jarves\Admin\FieldTypes\TypeInterface
  * @throws \Jarves\Exceptions\ObjectNotFoundException
  * @throws \Jarves\Exceptions\ObjectFieldNotFoundException
  * @throws \Jarves\Admin\FieldTypes\TypeNotFoundException
  */
 public function getFieldType()
 {
     if (null === $this->fieldType) {
         $type = $this->getType();
         $field = null;
         //            if ('predefined' === strtolower($type)) {
         //                $object = $this->getJarves()->getObjects()->getDefinition($this->getObject());
         //                if (!$object && $this->getObjectDefinition()) {
         //                    $object = $this->getObjectDefinition();
         //                }
         //                if (null === $object) {
         //                    throw new ObjectNotFoundException(
         //                        sprintf(
         //                            'Object `%s` for predefined field `%s` not found.',
         //                            $this->getObject(),
         //                            $this->getId()
         //                        )
         //                    );
         //                }
         //                if (!$fieldId = $this->getField()) {
         //                    $fieldId = $this->getId();
         //                }
         //
         //                if (!$field = $object->getField($fieldId)) {
         //                    throw new ObjectFieldNotFoundException(
         //                        sprintf(
         //                            'Field `%s` of Object `%s` for predefined field `%s` not found.',
         //                            $fieldId,
         //                            $object->getKey(),
         //                            $this->getId()
         //                        )
         //                    );
         //                }
         //                $type = $field->getType();
         //            }
         try {
             $this->fieldType = $this->getJarves()->getFieldTypes()->newType($type);
         } catch (\Exception $e) {
             if ($this->getObjectDefinition()) {
                 $message = sprintf('FieldType `%s` for field `%s` in object `%s` not found.', $type, $this->getId(), $this->getObjectDefinition()->getId());
             } else {
                 $message = sprintf('FieldType `%s` for field `%s` not found.', $type, $this->getId());
             }
             throw new TypeNotFoundException($message, 0, $e);
         }
         $this->fieldType->setFieldDefinition($field ?: $this);
     }
     return $this->fieldType;
 }