Nextras\Orm\Entity\Reflection\MetadataParser::processRelationshipEntityProperty PHP Méthode

processRelationshipEntityProperty() private méthode

private processRelationshipEntityProperty ( array &$args, PropertyMetadata $property )
$args array
$property PropertyMetadata
    private function processRelationshipEntityProperty(array &$args, PropertyMetadata $property)
    {
        static $modifiersMap = [PropertyRelationshipMetadata::ONE_HAS_MANY => '1:m', PropertyRelationshipMetadata::ONE_HAS_ONE => '1:1', PropertyRelationshipMetadata::MANY_HAS_ONE => 'm:1', PropertyRelationshipMetadata::MANY_HAS_MANY => 'm:m'];
        $modifier = $modifiersMap[$property->relationship->type];
        $class = array_shift($args);
        if ($class === null) {
            throw new InvalidModifierDefinitionException("Relationship {{$modifier}} in {$this->currentReflection->name}::\${$property->name} has not defined target entity and its property name.");
        }
        if (($pos = strpos($class, '::')) === false) {
            if (preg_match('#^[a-z0-9_\\\\]+$#i', $class) === 0) {
                throw new InvalidModifierDefinitionException("Relationship {{$modifier}} in {$this->currentReflection->name}::\${$property->name} has invalid class name of the target entity. Use Entity::\$property format.");
            } elseif (!(isset($args['oneSided']) && $args['oneSided'])) {
                throw new InvalidModifierDefinitionException("Relationship {{$modifier}} in {$this->currentReflection->name}::\${$property->name} has not defined target property name.");
            } else {
                $targetProperty = null;
                unset($args['oneSided']);
            }
        } else {
            $targetProperty = substr($class, $pos + 3);
            // skip ::$
            $class = substr($class, 0, $pos);
        }
        $entity = $this->makeFQN($class);
        if (!isset($this->entityClassesMap[$entity])) {
            throw new InvalidModifierDefinitionException("Relationship {{$modifier}} in {$this->currentReflection->name}::\${$property->name} points to unknown '{$entity}' entity.");
        }
        $property->relationship->entity = $entity;
        $property->relationship->repository = $this->entityClassesMap[$entity];
        $property->relationship->property = $targetProperty;
    }