/**
  * @param Schema\Field $field
  * @return array
  */
 protected function getBaseDefAsArray(Schema\Field $field)
 {
     return ['length' => $field->getLength(), 'title' => $field->getTitle(), 'description' => $field->getDescription(), 'readOnly' => $field->getReadOnly(), 'required' => $field->getRequired(), 'translatable' => $field->getTranslatable(), 'collection' => $field->getCollection(), 'xDynamicKey' => null, 'constraints' => array_map(function (Schema\Constraint $constraint) {
         return ['name' => $constraint->getName(), 'options' => array_map(function (Schema\ConstraintOption $option) {
             return ['name' => $option->getName(), 'value' => $option->getValue()];
         }, $constraint->getOptions())];
     }, $field->getConstraints())];
 }
Exemplo n.º 2
0
 /**
  * Gets the name this field should be exposed as (serializer concern).
  * Normally this is the name, but can be overriden by "exposeAs" property on the field.
  *
  * @return string exposed field name
  */
 private function getExposedName()
 {
     return $this->definition->getExposeAs() === null ? $this->getName() : $this->definition->getExposeAs();
 }
Exemplo n.º 3
0
 /**
  * @param string       $name       Field name
  * @param Schema\Field $definition Field
  *
  * @return DefinitionElementInterface
  */
 private function processSimpleField($name, Schema\Field $definition)
 {
     if (strpos($definition->getType(), 'class:') === 0) {
         $field = new JsonDefinitionRel($name, $definition, $this->getRelation($name));
     } else {
         $field = new JsonDefinitionField($name, $definition);
     }
     if (substr($definition->getType(), -2) === '[]') {
         $field = new JsonDefinitionArray($name, $field);
     }
     return $field;
 }