Push Ancestor for filter the query

@param $ancestor

@return $this
@throws \Aruberuto\Repository\Exceptions\RepositoryException
7209
public function pushAncestor($ancestor)
    {
        if (is_string($ancestor)) {
            $ancestor = new $ancestor;
        }
        if (!$ancestor instanceof AncestorCriteriaInterface) {
            throw new RepositoryException("Class " . get_class($ancestor) . " must be an instance of Aruberuto\\Repository\\Contracts\\AncestorCriteriaInterface");
        }
        $this->ancestor->push($ancestor);

        return $this;
    }
856572
protected function applyWhere(QueryBuilder $qb, array $where): void
    {
        $whereType = $this->getContext()->getDefinition()->getArgument('where')->getType();

        /** @var InputObjectDefinition $whereDefinition */
        $whereDefinition = $this->getContext()->getEndpoint()->getType($whereType);

        /** @var ObjectDefinition $node */
        $node = $this->getContext()->getEndpoint()->getType($this->getContext()->getDefinition()->getNode());

        foreach ($where as $filterName => $condition) {
            $filterDefinition = $whereDefinition->getField($filterName);

            //TODO: load filters from services
            /** @var FilterInterface $filter */
            $filter = (new \ReflectionClass($filterDefinition->getResolver()))->newInstanceWithoutConstructor();

            $fieldName = $filterDefinition->getMeta('filter_field');
            if ($fieldName && $node->hasField($fieldName)) {
                $relatedField = $node->getField($fieldName);
                $filterContext = new FilterContext($this->getContext()->getEndpoint(), $node, $relatedField);
            } else {
                $filterContext = new FilterContext($this->getContext()->getEndpoint(), $node);
            }

            $filter($filterContext, $qb, $condition);
        }
    }
208660
public function addFilter(string $key, string $value): Repository
	{
		$this->filters[$key] = $value;

		return $this;
	}
232504
public function makeRoot()
    {
        if ($this->getLeftValue() || $this->getRightValue()) {
            throw new PropelException('Cannot turn an existing node into a root node.');
        }

        $this->setLeftValue(1);
        $this->setRightValue(2);
        $this->setLevel(0);

        return $this;
    }
82694
public function hasAncestor($ancestor)
    {
        if (!$this->hasParent()) {
            return false;
        }
        if ($this->parent->getRefId() == $ancestor->getRefId()) {
            return true;
        }
        return $this->parent->hasAncestor($ancestor);
    }
18397
public function filter(ODataQueryFilterInterface $filter = NULL) {
        if (isset($filter)) {
            $this->setFilter($filter);
            return $this;
        }
        return $this->getFilter();
    }
35668
public function find(array $filter = [], array $orderBy = [], $limit = 0,
        $offset = 0, array $associate = []
    ) {
        try {

            $query = $this->query()
                ->select()
                ->associate($associate)
                ->setFilter($filter);

            foreach ($orderBy as $orderByRule) {
                $query->orderBy($orderByRule[0], $orderByRule[1]);
            }

            return $query->limit($limit)->offset($offset)->run($this->connection);
        } catch (Exception\QueryException $e) {
            throw new Exception\RepositoryException($e->getMessage());
        }
    }
507940
protected function getNewRealDepth($ancestor)
    {
        if (!$ancestor instanceof EntityInterface) {
            if (is_null($ancestor)) {
                return 0;
            } else {
                return static::find($ancestor)->real_depth + 1;
            }
        } else {
            return $ancestor->real_depth + 1;
        }
    }
608944
protected function inheritFromParent(BaseQuery $parent)
    {
        $this->macros = $parent->macros;
        $this->flags = $parent->flags;
        $this->resultFetcher = $parent->resultFetcher;   
    }
1261612
public function filterByPrimaryKey($key)
    {
        $this->addUsingAlias(StructureNodeParentTableMap::COL_STRUCTURE_NODE_ID, $key[0], Criteria::EQUAL);
        $this->addUsingAlias(StructureNodeParentTableMap::COL_PARENT_ID, $key[1], Criteria::EQUAL);

        return $this;
    }
416031
public function moveBefore($entity)
    {
        /* @var \Eloquent $this */
        $this->getConnection()->beginTransaction();

        if ($this->position > $entity->position) {
            $this->getConnection()->table($this->getTable())->where('position', '>=', $entity->position)->where(
                'position',
                '<',
                $this->position
            )->increment('position');
            $this->position = $entity->position;

            $entity->position = $entity->position + 1;
        } else {
            if ($this->position < $entity->position) {
                $this->getConnection()->table($this->getTable())->where('position', '<', $entity->position)->where(
                    'position',
                    '>',
                    $this->position
                )->decrement('position');
                $this->position = $entity->position - 1;
            }
        }

        $this->{ $this->getSaveMethod() }();

        $this->getConnection()->commit();
    }
1186466
public function addFilters(array $filters): Repository
	{
		foreach ($filters as $key => $value) {
			$this->addFilter($key, $value);
		}

		return $this;
	}
106684
public function setParent(InnerNode $parent): AbstractNode
    {
        // check integrity
        if ($this->isDescendant($parent->id())) {
            throw new CircularException('Can not add descendant "'.$parent->id().'" as my parent.');
        }

		// clear cache
		$this->clear();

        return parent::setParent($parent);
    }
429948
function ancestor(predicate, node) {
    while ((node = node.parent)) {
        if (predicate(node)) return true;
    }

    return false;
}
1200534
public function setParent($parent)
    {
        if (null !== $parent) {
            $this->entity->setParent($parent->getEntity());
        } else {
            $this->entity->setParent(null);
        }

        // FIXME remove cache for parent and generate it on the fly
        //       reason: preview images cannot be generated without a service
        $this->parent = $parent;

        return $this;
    }
594046
public function hasAncestor($itemName, $ancestorName)
    {
        $ancestors = $this->getAncestors($itemName);
        return isset($ancestors[$ancestorName]);
    }
1312585
public function pushData(EntityInterface $entity)
    {
        if ($this->isMany()) {
            $this->data[] = $entity;
            return $this;
        }
        $this->data = $entity;
        return $this;
    }