@param \Darvin\AdminBundle\Metadata\Metadata $meta     Metadata
@param string                                $property Property
@param object                                $entity   Entity

@return \Symfony\Component\Form\FormInterface
558801
public function createPropertyForm(Metadata $meta, $property, $entity)
    {
        $dataClass = $meta->getEntityClass();

        if (!empty($entity) && !$this->propertyAccessor->isWritable($entity, $property) && null !== $meta->getTranslationClass()) {
            /** @var \Knp\DoctrineBehaviors\Model\Translatable\Translatable $entity */
            $translations = $entity->getTranslations();

            /** @var \Knp\DoctrineBehaviors\Model\Translatable\Translation $translation */
            foreach ($translations as $translation) {
                if ($translation->getLocale() === $entity->getCurrentLocale()) {
                    $dataClass = $meta->getTranslationClass();
                    $entity = $translation;
                }
            }
        }

        return $this->genericFormFactory->createNamed($meta->getFormTypeName().'_property', BaseType::class, $entity, [
            'action_type'       => 'index',
            'data_class'        => $dataClass,
            'field_filter'      => $property,
            'metadata'          => $meta,
            'required'          => false,
            'validation_groups' => [
                'Default',
                'AdminUpdateProperty',
            ],
        ]);
    }
243849
protected function getMetaTag($property = null, $content = null)
    {
        return sprintf(
            "<meta property=\"%s\" content=\"%s\" />\n",
            Convert::raw2att($property),
            Convert::raw2att($content)
        );
    }
385935
private function collectAttributeTypeMetadata(
        PropertyMetadataBuilder $metadata,
        Attribute $attribute
    ) : void {
        $type = $attribute->type;

        // handle the case if the property type is mixed
        if ('mixed' === $type) {
            return;
        }

        if ($attribute->required) {
            $metadata->withBeingRequired();
        }

        // Evaluate type

        // Checks if the property has array<type>
        if (false !== $pos = strpos($type, '<')) {
            $arrayType = substr($type, $pos + 1, -1);

            $metadata->withType(new ArrayType(new MixedType(), $this->createTypeFromName($arrayType)));

            return;
        }

        // Checks if the property has type[]
         if (false !== $pos = strrpos($type, '[')) {
            $arrayType = substr($type, 0, $pos);

            $metadata->withType(new ArrayType(new MixedType(), $this->createTypeFromName($arrayType)));

            return;
        }

        $metadata->withType($this->createTypeFromName($attribute->type));
    }
248394
protected function addPropertyMetadata(PropertyMetadata $metadata, $name, array $option = [])
    {
        $obj = $this->getOption($name);
        $meta = new Metadata($name, $this->resolveOptions($obj, $option));
        if ($obj instanceof AdvancedVisibilityInterface) {
            $metadata->addAdvancedVisibility($meta);
        }
        if ($obj instanceof VisibilityInterface) {
            $metadata->addVisibility($meta);
        }
        if ($obj instanceof AccessorInterface) {
            $metadata->setAccessor($meta);
        }
        if ($obj instanceof NameConverterInterface) {
            $metadata->addNameConverter($meta);
        }

        return $this;
    }
878599
private function register(Entity $meta): self
    {
        $this->mapping = $this->mapping->put((string) $meta->class(), $meta);

        return $this;
    }
271740
private function readProperty(ReflectionProperty $property, ClassMetadataInterface $metadata)
    {
        // Skip if this property is not from this class
        if ($property->getDeclaringClass()->getName()
            != $metadata->getClassName()
        ) {
            return;
        }

        //Iterate over all annotations
        foreach ($this->reader->getPropertyAnnotations($property) as $rule) {

            //Skip is its not a rule
            if (! $rule instanceof Rules\Rule) {
                continue;
            }

            //Add Rule
            $metadata->addPropertyRule($property->getName(), $rule);
        }
    }
664415
public function bind($entity, array $data)
    {
        $meta = $this->getMeta();

        foreach ($data as $key => $value) {
            if (is_null($value)) {
                continue;
            }

            if (array_key_exists($key, $meta->fields)) {
                $property            = $meta->propertyName($key);
                $entity->{$property} = $value;
            }
        }

        $this->unitOfWork->getEntityRegistry()->getEntityBuilder()->resolve($entity);
    }
787413
public function save(ClassMetadata $meta, Component $component, &$entity): bool
    {
        if (is_object($entity)) {
            return false;
        }

        $reflection = $meta->getReflectionClass();
        $constructor = $reflection->getConstructor();

        if ($constructor) {
            $constructorNewParameters = [];

            /** @var Container|null $baseComponent */
            $baseComponent = $component instanceof Container ? $component : $component->getParent();

            if ($baseComponent === null) {
                throw new InvalidStateException(__METHOD__ . ' cannot found container');
            }

            foreach ($constructor->getParameters() as $constructorParameter) {
                // property name
                $name = $constructorParameter->getName();

                /** @var BaseControl|Container|null $child */
                $child = $baseComponent->getComponent($name, false);

                // test if parameter is required and control exists
                if ($child === null && $constructorParameter->isOptional() === false) {
                    throw new InvalidStateException("Can't create new instance: control '$name' is missing");
                }

                if ($child === null) {
                    continue;
                }

                if ($meta->hasAssociation($name) === false) {
                    if ($child instanceof Container) {
                        throw new InvalidStateException('Scalar type and form container? What is wrong with you?');
                    }
                    // scalar type
                    $constructorNewParameters[$name] = $child->getValue();
                    continue;
                }

                // object type
                $targetClass = $meta->getAssociationTargetClass($name);

                if ($child instanceof Container) {
                    // probably OneToOne Container
                    $this->save($this->entityManager->getClassMetadata($targetClass), $child, $targetClass);
                    // $targetClass is new instance
                    $constructorNewParameters[$name] = $targetClass;
                } elseif ($child instanceof BaseControl) {
                    $constructorNewParameters[$name] = $this->entityManager->find($targetClass, $child->getValue());
                }
            }

            $entity = $reflection->newInstanceArgs($constructorNewParameters);
        } else {
            $entity = $reflection->newInstanceWithoutConstructor();
        }

        return false;
    }
885220
private function _initMany($property, $method, $mode, $sourcePrimary) {
		$collection = $this->getCollection();
		
		$data = $collection->__call($method);
		if ($data === null) return;

		if ($data instanceof Collection) {
			if ($data->hasMetadata()) {
				$meta = $data->getMetadata();

				$onProperty     = $meta->joinOnProperty;
				$sourceProperty = $meta->joinOnSource;
			} else {
				$onProperty     = null;
				$sourceProperty = null;
			}

			if ($mode === self::MODE_CASCADE) {
				// If not specified in meta, using a requested property
				if ($onProperty === null) {
					$onProperty = $property;
				}

				// If not specified in meta:
				if ($sourceProperty === null) {
					if ($sourcePrimary === null) {
						// Attempt to get from source collection
						$sourceProperty = $data->getPrimary();

						if ($sourceProperty === null) {
							throw new Exception('Unable to determine a source property for join');
						}
					} else {
						// Manually specified
						$sourceProperty = $sourcePrimary;
					}
				}
			}

			if ($mode === self::MODE_JOIN) {
				$collection->join($data, $onProperty, $sourceProperty);
			}
			else if ($mode === self::MODE_CASCADE || $mode === self::MODE_CASCADE_MANY) {
				$collection->setList($onProperty, $data->toArray(), $sourceProperty);
			}
			else {
				throw new Exception('Uncnown loading mode');
			}
		} else {
			throw new Exception('Data must be represented as a collection');
		}
	}
356283
private function readProperty($property, $metadata)
    {
        $reflClass = $metadata->getReflectionClass();
        
        // Skip if this property is not from this class
        if ($property->getDeclaringClass()->getName()
            != $metadata->getClassName()
        ) {
            return;
        }

        //Iterate over all annotations
        foreach($this->reader->getPropertyAnnotations($property) as $rule) {

            //Skip is its not a rule
            if ( ! $rule instanceof Rules\Rule ) continue;
            
            //Add Rule
            $metadata->addPropertyRule($property->getName(), $rule);

        }

    }
837781
protected function getPropertyValueFromObject(ClassMetadata $meta, $propertyName, $object)
    {
        $refl = $meta->getReflectionClass();
        $prop = $refl->getProperty($propertyName);
        $prop->setAccessible(true);
        $value = $prop->getValue($object);
        return $value;
    }
1227861
private function toDocument(MetaInformationInterface $metaInformation): DocumentInterface
    {
        $doc = $this->entityMapper->toDocument($metaInformation);

        return $doc;
    }
447526
public function create(string $resourceClass, string $property, array $options = []): PropertyMetadata
    {
        $propertyMetadata = $this->propertyMetadata->create($resourceClass, $property, $options);

        if ('code' === $property && is_a($resourceClass, FamilyInterface::class, true)) {
            return $propertyMetadata->withIdentifier(true);
        }

        return $propertyMetadata;
    }
532547
public function validateMetadataInheritance(EntityMetadata $metadata, MetadataFactory $mf)
    {
        if (true === $metadata->isPolymorphic()) {
            foreach ($metadata->ownedTypes as $child) {

                if (false === $this->isEntityTypeValid($child)) {
                    throw MetadataException::invalidMetadata($metadata->type, sprintf('The owned entity type "%s" is invalid based on the configured name format "%s"', $child, $this->config->getEntityFormat()));
                }

                if (false === $mf->metadataExists($child)) {
                    throw MetadataException::invalidMetadata($metadata->type, sprintf('The entity owns a type "%s" that does not exist.', $child));
                }
            }
        }

        if (false === $metadata->isPolymorphic() && true === $metadata->isAbstract()) {
            throw MetadataException::invalidMetadata($metadata->type, 'An entity must be polymorphic to be abstract.');
        }

        if (false === $metadata->isChildEntity()) {
            return true;
        }
        if (true === $metadata->isPolymorphic()) {
            throw MetadataException::invalidMetadata($metadata->type, 'An entity cannot both be polymorphic and be a child.');
        }
        if ($metadata->extends === $metadata->type) {
            throw MetadataException::invalidMetadata($metadata->type, 'An entity cannot extend itself.');
        }

        if (false === $mf->metadataExists($metadata->extends)) {
            throw MetadataException::invalidMetadata($metadata->type, sprintf('The parent entity type "%s" does not exist.', $metadata->extends));
        }

        $parent = $mf->getMetadataForType($metadata->extends);
        if (false === $parent->isPolymorphic()) {
            throw MetadataException::invalidMetadata($metadata->type, sprintf('Parent classes must be polymorphic. Parent entity "%s" is not polymorphic.', $metadata->extends));
        }
        return true;
    }
248224
public function createProperty(ItemMetadata $property, StructureInterface $structure = null)
    {
        if ($property instanceof SectionMetadata) {
            return $this->createSectionProperty($property, $structure);
        }

        if ($property instanceof BlockMetadata) {
            return $this->createBlockProperty($property, $structure);
        }

        if (null === $property->getType()) {
            throw new \RuntimeException(sprintf(
                'Property name "%s" has no type.',
                $property->getName()
            ));
        }

        $parameters = $this->convertArrayToParameters($property->getParameters());
        $propertyBridge = new LegacyProperty(
            $property->getName(),
            [
                'title' => $property->getTitles(),
                'info_text' => $property->getDescriptions(),
                'placeholder' => $property->getPlaceholders(),
            ],
            $property->getType(),
            $property->isRequired(),
            $property->isLocalized(),
            $property->getMaxOccurs(),
            $property->getMinOccurs(),
            $parameters,
            [],
            $property->getColSpan()
        );

        foreach ($property->getTags() as $tag) {
            $propertyBridge->addTag(new PropertyTag($tag['name'], $tag['priority'], $tag['attributes']));
        }

        $propertyBridge->setStructure($structure);

        return $propertyBridge;
    }
985123
public function shouldSkipProperty(PropertyMetadata $property, Context $context): bool
    {
        return $property->name === 'type' && $this->isCurrentlyExcluded;
    }
203647
private function parseMetadataProperty(\ReflectionProperty $property)
    {
        $metadata = array();
        $tag = '@var';
        $docComment = $property->getDocComment();
        $occurence = (int) substr_count($docComment, $tag);

        if (1 < $occurence) {
            throw new \RuntimeException(sprintf('"@var" tag is not unique for "%s->%s"', $property->getDeclaringClass()->getName(), $property->getName()));
        }

        $metadata['attribute'] = $property->getName();

        // Grep type and optional namespaces
        preg_match('#@var\h+([a-zA-Z0-9\\\\_]+)(?:\h+\[([a-zA-Z0-9\\\\\s,_]+)\]\h*|.*)\v#', $docComment, $captured);

        if (!empty($captured)) {

            // Format var metadata
            $metadata['type'] = $captured[1];

            if (isset($captured[2])) {
                $metadata['mappedClass'] = trim($captured[2]);
            }
        }

        return $metadata;
    }