Nextras\Orm\Collection\Helpers\ArrayCollectionHelper::getter PHP Méthode

getter() public méthode

public getter ( $element, $chain, EntityMetadata $sourceEntityMeta )
$sourceEntityMeta Nextras\Orm\Entity\Reflection\EntityMetadata
    public function getter($element, $chain, EntityMetadata $sourceEntityMeta)
    {
        $column = array_shift($chain);
        $propertyMeta = $sourceEntityMeta->getProperty($column);
        // check if property exists
        $value = $element->hasValue($column) ? $element->getValue($column) : null;
        if ($value instanceof IRelationshipCollection) {
            throw new InvalidStateException('You can not sort by hasMany relationship.');
        }
        if (!$chain) {
            return $this->normalizeValue($value, $propertyMeta);
        } else {
            $targetEntityMeta = $this->metadataStorage->get($propertyMeta->relationship->entity);
            return $this->getter($value, $chain, $targetEntityMeta);
        }
    }