/**
  * @param Attribute $attribute
  * @throws AssemblerException If attribute is invalid
  */
 protected function assertAttributeHasValidType(Attribute $attribute)
 {
     $attributeType = $attribute->getType();
     $allowedTypes = array('bool', 'boolean', 'int', 'integer', 'float', 'string', 'array', 'object', 'entity');
     if (!in_array($attributeType, $allowedTypes)) {
         throw new AssemblerException(sprintf('Invalid attribute type "%s", allowed types are "%s"', $attributeType, implode('", "', $allowedTypes)));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function supportsDenormalization(Workflow $workflow, Attribute $attribute, $attributeValue)
 {
     return $attribute->getType() == 'entity';
 }
Exemplo n.º 3
0
 /**
  * @param Attribute $attribute
  * @return null|TypeGuess
  */
 public function guessAttributeForm(Attribute $attribute)
 {
     $attributeType = $attribute->getType();
     if ($attributeType === 'entity') {
         list($formType, $formOptions) = $this->getEntityForm($attribute->getOption('class'));
     } elseif (isset($this->formTypeMapping[$attributeType])) {
         $formType = $this->formTypeMapping[$attributeType]['type'];
         $formOptions = $this->formTypeMapping[$attributeType]['options'];
     } else {
         return null;
     }
     return new TypeGuess($formType, $formOptions, TypeGuess::VERY_HIGH_CONFIDENCE);
 }
 /**
  * {@inheritdoc}
  */
 public function supportsDenormalization(Workflow $workflow, Attribute $attribute, $attributeValue)
 {
     return !empty($this->normalTypes[$attribute->getType()]);
 }