/**
  * @param FormInterface      $form
  * @param AttributeInterface $attribute
  * @param FamilyInterface    $family
  * @param DataInterface      $data
  * @param array              $options
  *
  * @throws \Exception
  */
 protected function addMultipleAttribute(FormInterface $form, AttributeInterface $attribute, FamilyInterface $family, DataInterface $data = null, array $options = [])
 {
     $formOptions = [];
     if (array_key_exists('form_options', $options)) {
         $formOptions = $options['form_options'];
     }
     $formOptions = array_merge($formOptions, $attribute->getFormOptions($data));
     $label = $this->getFieldLabel($family, $attribute);
     $formOptions['label'] = false;
     // Removing label
     $collectionOptions = ['label' => $label, 'type' => $attribute->getType()->getFormType(), 'entry_options' => $formOptions, 'allow_add' => true, 'allow_delete' => true, 'required' => $attribute->isRequired(), 'sortable' => false, 'prototype_name' => '__' . $attribute->getCode() . '__'];
     if (!empty($formOptions['collection_options'])) {
         $collectionOptions = array_merge($collectionOptions, $formOptions['collection_options']);
     }
     unset($collectionOptions['entry_options']['collection_options']);
     $form->add($attribute->getCode(), $this->collectionType, $collectionOptions);
 }
 /**
  * @param FamilyInterface    $family
  * @param AttributeInterface $attribute
  * @return string
  */
 protected function getPHPType(FamilyInterface $family, AttributeInterface $attribute)
 {
     $type = substr($attribute->getType()->getDatabaseType(), 0, -strlen('Value'));
     // Scalar types
     if (in_array($type, ['bool', 'integer', 'decimal', 'string', 'text'], true)) {
         if ($attribute->isMultiple()) {
             return 'array';
         }
         if ('text' === $type) {
             return 'string';
         } elseif ('decimal' === $type) {
             return 'double';
         }
         return $type;
     }
     if (in_array($type, ['date', 'datetime'], true)) {
         $type = '\\DateTime';
         if ($attribute->isMultiple()) {
             $type .= '[]';
         }
         return $type;
     }
     if ('data' === $type) {
         $formOptions = $attribute->getFormOptions();
         // Simple case
         if (array_key_exists('family', $formOptions)) {
             $type = $formOptions['family'];
             if ($attribute->isMultiple()) {
                 $type .= '[]';
             }
             return $type;
         }
         // Multiple families (some case)
         if (array_key_exists('families', $formOptions)) {
             $types = $formOptions['families'];
             if (!is_array($types)) {
                 return 'mixed';
                 // Shouldn't happen
             }
             if ($attribute->isMultiple()) {
                 foreach ($types as &$type) {
                     $type .= '[]';
                 }
             }
             return implode('|', $types);
         }
         // Couldn't find any family (rare case)
         if ($attribute->isMultiple()) {
             return 'array';
         }
         return 'mixed';
     }
     // Then there are the custom relation cases:
     $type = $this->getTargetClass($family, $attribute);
     if ($type) {
         return $type;
     }
     // Fallback in any other case
     if ($attribute->isMultiple()) {
         return 'array';
     }
     return 'mixed';
 }