eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Gateway\DoctrineDatabase::loadPathDataByHierarchy PHP Method

loadPathDataByHierarchy() public method

The first entry in $hierarchyData corresponds to the top-most path element in the path, the second entry the child of the first path element and so on. This method is faster than self::getPath() since it can fetch all elements using only one query, but can be used only for autogenerated paths.
public loadPathDataByHierarchy ( array $hierarchyData ) : array
$hierarchyData array
return array
    public function loadPathDataByHierarchy(array $hierarchyData)
    {
        /** @var $query \eZ\Publish\Core\Persistence\Database\SelectQuery */
        $query = $this->dbHandler->createSelectQuery();
        $hierarchyConditions = array();
        foreach ($hierarchyData as $levelData) {
            $hierarchyConditions[] = $query->expr->lAnd($query->expr->eq($this->dbHandler->quoteColumn('parent'), $query->bindValue($levelData['parent'], null, \PDO::PARAM_INT)), $query->expr->eq($this->dbHandler->quoteColumn('action'), $query->bindValue($levelData['action'], null, \PDO::PARAM_STR)), $query->expr->eq($this->dbHandler->quoteColumn('id'), $query->bindValue($levelData['id'], null, \PDO::PARAM_INT)));
        }
        $query->select($this->dbHandler->quoteColumn('action'), $this->dbHandler->quoteColumn('lang_mask'), $this->dbHandler->quoteColumn('text'))->from($this->dbHandler->quoteTable($this->table))->where($query->expr->lOr($hierarchyConditions));
        $statement = $query->prepare();
        $statement->execute();
        $rows = $statement->fetchAll(\PDO::FETCH_ASSOC);
        $rowsMap = array();
        foreach ($rows as $row) {
            $rowsMap[$row['action']][] = $row;
        }
        if (count($rowsMap) !== count($hierarchyData)) {
            throw new \RuntimeException('The path is corrupted.');
        }
        $data = array();
        foreach ($hierarchyData as $levelData) {
            $data[] = $rowsMap[$levelData['action']];
        }
        return $data;
    }