public function postLoad(LifecycleEventArgs $args)
 {
     $field = $args->getEntity();
     if (!$field instanceof Field) {
         return;
     }
     $type = $this->typeFactory->create($field->getType());
     $this->injectType($field, $type);
 }
 public function buildCollection(Document $document)
 {
     $fields = new FieldCollection();
     $definition = $this->registry->findDefinitionFor($document);
     $fieldFactory = $definition->getFieldFactory();
     $configuration = $definition->getConfigurationFor($document);
     foreach ($configuration as $name => $attributes) {
         $type = $this->extract($attributes, 'type');
         $label = $this->extract($attributes, 'label');
         $value = $this->extract($attributes, 'value');
         $type = $this->typeFactory->create($type);
         $field = $fieldFactory->createField($document, $name, $type, $label, $value);
         $fields->addField($field);
     }
     return $fields;
 }