/**
  * {@inheritDoc}
  */
 public function preSetData(FormEvent $event)
 {
     $characteristics = $event->getData();
     if (!$characteristics instanceof AbstractCharacteristics) {
         throw new \InvalidArgumentException(sprintf('Expected AbstractCharacteristics instance, got "%s".', get_class($characteristics)));
     }
     $schema = $this->manager->getSchemaForClass($characteristics);
     $parentCharacteristics = $this->manager->getInheritedCharacteristics($characteristics);
     $form = $event->getForm();
     $form->add('characteristics', new CharacteristicsCollectionType($this->manager, $this->em, $schema, $parentCharacteristics), ['label' => false, 'by_reference' => false]);
 }
 /**
  * Fills the data with the proper characteristic type.
  *
  * @param \Doctrine\Common\Collections\Collection $data
  * @param \Ekyna\Component\Characteristics\Schema\Definition $definition
  * @throws \InvalidArgumentException
  */
 private function appendProperData(Collection $data, Definition $definition)
 {
     $identifier = $definition->getIdentifier();
     if ($data->offsetExists($identifier)) {
         return;
     }
     $characteristic = $this->manager->createCharacteristicFromDefinition($definition);
     $data->set($identifier, $characteristic);
 }