@param               $index
@param string        $name
@param iterable|null $relationshipFilters
@param iterable|null $relationshipSorts

@return PaginatedDataInterface
434198
protected function readRelationshipInt(
        $index,
        string $name,
        iterable $relationshipFilters = null,
        iterable $relationshipSorts = null
    ): PaginatedDataInterface {
        return parent::readRelationship($index, $name, $relationshipFilters, $relationshipSorts);
    }
641640
public function filter($name, array $options = [])
    {
        $result = static::INT_FILTER;

        if ($this->isMultipartImage()) {
            $this->resource = $this->resource->coalesceImages();
        }

        foreach ($this->resource as $frame) {
            $result = $this->callParentFilter($name, $options);
        }


        if (static::EXT_FILTER === $result and isset($this->filters[$name])) {

            $filter = new $this->filters[$name]($this, $options);

            foreach ($this->resource as $frame) {
                $filter->run();
            }
        }

    }
95098
public function addSecondaryIndex(Index $index)
    {
        if ($this->isEmbeddedDocument) {
            throw MappingException::embeddedDocumentsNotIndexable($this->getName());
        }

        if (isset($this->secondaryIndexes[$index->getName()])) {
            throw MappingException::indexExists($this->getName(), $index->getName());
        }

        $this->secondaryIndexes[$index->getName()] = $index;
    }
591612
public function get($name, $index = 0)
    {
        $name = strtolower($name);

        if (func_num_args() < 2) {
            if ($this->has($name)) {
                $values = array_values($this->headers[$name]);

                return array_shift($values);
            }
        } else {
            if ($this->has($name, $index)) {
                return $this->headers[$name][$index];
            }
        }
    }
1206131
public function indexRelationship($resourceId, $relationshipName, EncodingParametersInterface $parameters)
    {
        $resource = $this->read($resourceId);

        /** @var Relation $relation */
        $relation = $resource->{$relationshipName}();

        $result = $this->paginateBuilder($relation->getQuery(), $parameters);

        $this->applyIndexPolicy($result->getData());

        return $result;
    }
1060507
public function GroupedBy($index, $children = 'Children')
    {
        $grouped = $this->groupBy($index);
        $result  = new ArrayList();

        foreach ($grouped as $indVal => $list) {
            $list = GroupedList::create($list);
            $result->push(new ArrayData(array(
                $index    => $indVal,
                $children => $list
            )));
        }

        return $result;
    }
43686
public function getRelationIfSet($name)
    {
        return array_key_exists($name, $this->relations)
            ? $this->relations[$name]
            : null;
    }
848574
protected function generateRelationOptionsArray($name, Annotation $annotation, EntityDefinition &$entityMetadata)
    {
        $options = [];

        // belongsTo relation
        if ($annotation->type == 'belongsTo') {
            $options['relatedForeignKey'] = $annotation->relatedForeignKey ?: $this->generateKey($annotation->relatedEntity);
            $options['localKey'] = $annotation->localKey ?: 'id';
            $options['relation'] = $annotation->relation;
        }

        // belongsToMany relation
        if ($annotation->type == 'belongsToMany') {
            $options['pivotTable'] = $annotation->pivotTable ?: $this->generatePivotTablename($entityMetadata['class'], $annotation->relatedEntity, $annotation->inverse);
            $options['localPivotKey'] = $annotation->localPivotKey ?: $this->generateKey($entityMetadata['class']);
            $options['relatedPivotKey'] = $annotation->relatedPivotKey ?: $this->generateKey($annotation->relatedEntity);
            $options['relation'] = $annotation->relation;
        }

        // hasMany relation
        if ($annotation->type == 'hasMany') {
            $options['localForeignKey'] = $annotation->localForeignKey ?: $this->generateKey($entityMetadata['class']);
            $options['localKey'] = $annotation->localKey ?: 'id';
        }

        // hasManyThrough relation
        if ($annotation->type == 'hasManyThrough') {
            $options['throughEntity'] = $annotation->throughEntity;
            $options['localForeignKey'] = $annotation->localForeignKey ?: $this->generateKey($entityMetadata['class']);
            $options['throughForeignKey'] = $annotation->throughForeignKey ?: $this->generateKey($annotation->throughEntity);
        }

        // hasOne relation
        if ($annotation->type == 'hasOne') {
            $options['localForeignKey'] = $annotation->localForeignKey ?: $this->generateKey($entityMetadata['class']);
            $options['localKey'] = $annotation->localKey ?: 'id';
        }

        // morphMany relation
        if ($annotation->type == 'morphMany') {
            $options['morphName'] = $annotation->morphName ?: $name;
            $options['morphType'] = $annotation->morphType;
            $options['morphId'] = $annotation->morphId;
            $options['localKey'] = $annotation->localKey ?: 'id';
        }

        // morphOne relation
        if ($annotation->type == 'morphOne') {
            $options['morphName'] = $annotation->morphName ?: $name;
            $options['morphType'] = $annotation->morphType;
            $options['morphId'] = $annotation->morphId;
            $options['localKey'] = $annotation->localKey ?: 'id';
        }

        // morphTo relation
        if ($annotation->type == 'morphTo') {
            $options['morphName'] = $annotation->morphName ?: $name;
            $options['morphType'] = $annotation->morphType;
            $options['morphId'] = $annotation->morphId;
        }

        // morphToMany relation
        if ($annotation->type == 'morphToMany') {
            $options['morphName'] = $annotation->morphName ?: $name;
            $options['pivotTable'] = $annotation->pivotTable ?: $this->generatePivotTablename($entityMetadata['class'], $annotation->relatedEntity, $annotation->inverse, $annotation->morphName);
            if ($annotation->inverse) {
                $options['localPivotKey'] = $annotation->localPivotKey ?: $this->generateKey($entityMetadata['class']);
                $options['relatedPivotKey'] = $annotation->morphName.'_id';
            } else {
                $options['localPivotKey'] = $annotation->morphName.'_id';
                $options['relatedPivotKey'] = $annotation->relatedPivotKey ?: $this->generateKey($annotation->relatedEntity);
            }
            $options['inverse'] = $annotation->inverse;
        }

        return $options;
    }
654081
public function remove($name, $index = 0)
    {
        $lowerName = strtolower($name);
        unset($this->headers[$lowerName][$index]);
    }
696433
public function loadRelated($name, $values)
    {
        if (array_key_exists($name, $this->_relations)) {
            $relation = $this->_relations[$name];
        } else {
            $relation = $this->_relations[$name] = $this->getRelation($name, false);
        }

        if ($relation === null) {
            return false;
        }
        $class = $relation->modelClass;
        $multiple = $relation->multiple;
        $link = $relation->link;
        if (array_key_exists($name, $this->_originalRelations)) {
            $children = $this->_originalRelations[$name];
        } else {
            $this->_originalRelations[$name] = $children = $this->$name;
        }

        if ($multiple) {
            $newChildren = [];
            foreach ($values as $index => $item) {
                if (isset($children[$index])) {
                    if ($item instanceof $class) {
                        if ($item->isNewRecord || $item->oldPrimaryKey == $children[$index]->oldPrimaryKey) {
                            $item->oldAttributes = $children[$index]->oldAttributes;
                            unset($children[$index]);
                        }
                        $newChildren[$index] = $item;
                        if (isset($this->_relatedScenario[$name])) {
                            $newChildren[$index]->setScenario($this->_relatedScenario[$name]);
                        }
                    } else {
                        $newChildren[$index] = $children[$index];
                        if (isset($this->_relatedScenario[$name])) {
                            $newChildren[$index]->setScenario($this->_relatedScenario[$name]);
                        }
                        $newChildren[$index]->setAttributes($item);
                        unset($children[$index]);
                    }
                } elseif ($item instanceof $class) {
                    $newChildren[$index] = $item;
                    if (isset($this->_relatedScenario[$name])) {
                        $newChildren[$index]->setScenario($this->_relatedScenario[$name]);
                    }
                } else {
                    $newChildren[$index] = new $class();
                    if (isset($this->_relatedScenario[$name])) {
                        $children[$index]->setScenario($this->_relatedScenario[$name]);
                    }
                    $newChildren[$index]->setAttributes($item);
                }
                foreach ($link as $from => $to) {
                    $newChildren[$index]->$from = $this->$to;
                }
            }
            $this->_oldRelations[$name] = $children;
        } else {
            $item = $values;
            $newChildren = null;
            if (isset($children)) {
                if ($item instanceof $class) {
                    if ($item->isNewRecord || $item->oldPrimaryKey == $children->oldPrimaryKey) {
                        $item->oldAttributes = $children->oldAttributes;
                        $children = null;
                    }
                    $newChildren = $item;
                    if (isset($this->_relatedScenario[$name])) {
                        $newChildren->setScenario($this->_relatedScenario[$name]);
                    }
                } elseif (isset($item)) {
                    $newChildren = $children;
                    if (isset($this->_relatedScenario[$name])) {
                        $newChildren->setScenario($this->_relatedScenario[$name]);
                    }
                    $newChildren->setAttributes($item);
                    $children = null;
                }
            } elseif ($item instanceof $class) {
                $newChildren = $item;
                if (isset($this->_relatedScenario[$name])) {
                    $newChildren->setScenario($this->_relatedScenario[$name]);
                }
            } elseif (isset($item)) {
                $newChildren = new $class();
                if (isset($this->_relatedScenario[$name])) {
                    $newChildren->setScenario($this->_relatedScenario[$name]);
                }
                $newChildren->setAttributes($item);
            }
            if ($newChildren) {
                foreach ($link as $from => $to) {
                    $newChildren->$from = $this->$to;
                }
            }
            $this->_oldRelations[$name] = isset($children) ? [$children] : [];
        }
        $this->populateRelation($name, $newChildren);
        $this->_processRelations[$name] = true;
        return true;
    }
498702
public function addFilter($index, $method = null, ...$params)
    {
        $this->filters[$index] = [$method, $params];
        return $this;
    }
960117
protected static function _relations($type = null, $name = null) {
		$self = static::_object();

		if ($name) {
			if (isset($self->_relationsToLoad[$name])) {
				$t = $self->_relationsToLoad[$name];
				unset($self->_relationsToLoad[$name]);
				return static::bind($t, $name, (array) $self->{$t}[$name]);
			}
			return isset($self->_relations[$name]) ? $self->_relations[$name] : null;
		}
		if (!$type) {
			foreach ($self->_relationsToLoad as $name => $t) {
				static::bind($t, $name, (array) $self->{$t}[$name]);
			}
			$self->_relationsToLoad = [];
			return $self->_relations;
		}
		foreach ($self->_relationsToLoad as $name => $t) {
			if ($type === $t) {
				static::bind($t, $name, (array) $self->{$t}[$name]);
				unset($self->_relationsToLoad[$name]);
			}
		}
		return array_filter($self->_relations, function($i) use ($type) {
			return $i->data('type') === $type;
		});
	}
421403
public function siblings($index = null)
    {
        if (!is_null($index)) {
            return Arr::get($this->parent->filters(), $index);
        }

        return $this->parent->filters();
    }
284214
public function getNgRestRelationByIndex($index)
    {
        $relations = $this->generateNgRestRelations();

        return isset($relations[$index]) ? $relations[$index] : false;
    }
391723
protected function createPaginatedQueryBuilder(array $criteria = [], $indexBy = null, array $orderBy = null)
    {
        $qb = new PaginatedQueryBuilder($this->_em);
        $qb->from($this->_entityName, $this->getEntityAlias(), $indexBy);

        $this->processCriteria($qb, $criteria);

        return $qb;
    }
382569
private function queryOrderBuilder($query, array $sortParameters)
    {
        $model = $this;

        list($column, $direction) = $this->parseParameters($sortParameters);

        if (is_null($column)) {
            return $query;
        }

        $explodeResult = SortableLink::explodeSortParameter($column);
        if ( ! empty($explodeResult)) {
            $relationName = $explodeResult[0];
            $column       = $explodeResult[1];

            try {
                $relation = $query->getRelation($relationName);
                $query    = $this->queryJoinBuilder($query, $relation);
            } catch (BadMethodCallException $e) {
                throw new ColumnSortableException($relationName, 1, $e);
            } catch (\Exception $e) {
                throw new ColumnSortableException($relationName, 2, $e);
            }

            $model = $relation->getRelated();
        }

        if (method_exists($model, camel_case($column).'Sortable')) {
            return call_user_func_array([$model, camel_case($column).'Sortable'], [$query, $direction]);
        }

        if (isset($model->sortableAs) && in_array($column, $model->sortableAs)) {
            $query = $query->orderBy($column, $direction);
        } elseif ($this->columnExists($model, $column)) {
            $column = $model->getTable().'.'.$column;
            $query  = $query->orderBy($column, $direction);
        }

        return $query;
    }
995434
public function getFiltersTargetedArgs($index = 0)
    {
        return $this->propertyFilters !== null ? $this->propertyFilters->getFiltersTargetedArgs($index) : null;
    }