Loads complete URL alias data by given array of path hashes.
abstract public loadUrlAliasData ( array $urlHashes ) : array | ||
$urlHashes | array | URL string hashes |
Результат | array |
/** * Loads complete URL alias data by given array of path hashes. * * @param string[] $urlHashes URL string hashes * * @return array */ public function loadUrlAliasData(array $urlHashes) { try { return $this->innerGateway->loadUrlAliasData($urlHashes); } catch (DBALException $e) { throw new \RuntimeException('Database error', 0, $e); } catch (PDOException $e) { throw new \RuntimeException('Database error', 0, $e); } }
/** * Looks up a url alias for the given url. * * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException * @throws \RuntimeException * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException * * @param string $url * * @return \eZ\Publish\SPI\Persistence\Content\UrlAlias */ public function lookup($url) { $urlHashes = array(); foreach (explode('/', $url) as $level => $text) { $urlHashes[$level] = $this->getHash($text); } $data = $this->gateway->loadUrlAliasData($urlHashes); if (empty($data)) { throw new NotFoundException('URLAlias', $url); } $pathDepth = count($urlHashes); $hierarchyData = array(); $isPathHistory = false; for ($level = 0; $level < $pathDepth; ++$level) { $prefix = $level === $pathDepth - 1 ? '' : 'ezurlalias_ml' . $level . '_'; $isPathHistory = $isPathHistory ?: $data[$prefix . 'link'] != $data[$prefix . 'id']; $hierarchyData[$level] = array('id' => $data[$prefix . 'id'], 'parent' => $data[$prefix . 'parent'], 'action' => $data[$prefix . 'action']); } $data['is_path_history'] = $isPathHistory; $data['raw_path_data'] = $data['action_type'] == 'eznode' && !$data['is_alias'] ? $this->gateway->loadPathDataByHierarchy($hierarchyData) : $this->gateway->loadPathData($data['id']); return $this->mapper->extractUrlAliasFromData($data); }
/** * Looks up a url alias for the given url * * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException * @throws \RuntimeException * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException * * @param string $url * * @return \eZ\Publish\SPI\Persistence\Content\UrlAlias */ public function lookup($url) { $urlHashes = array(); foreach (explode("/", $url) as $level => $text) { $urlHashes[$level] = $this->getHash($text); } $data = $this->gateway->loadUrlAliasData($urlHashes); if (empty($data)) { throw new NotFoundException("URLAlias", $url); } $pathDepth = count($urlHashes); $hierarchyData = array(); $isPathHistory = false; for ($level = 0; $level < $pathDepth; ++$level) { $prefix = $level === $pathDepth - 1 ? "" : "ezurlalias_ml" . $level . "_"; $isPathHistory = $isPathHistory ?: $data[$prefix . "link"] != $data[$prefix . "id"]; $hierarchyData[$level] = array("id" => $data[$prefix . "id"], "parent" => $data[$prefix . "parent"], "action" => $data[$prefix . "action"]); } $data["is_path_history"] = $isPathHistory; $data["raw_path_data"] = $data["action_type"] == "eznode" && !$data["is_alias"] ? $this->gateway->loadPathDataByHierarchy($hierarchyData) : $this->gateway->loadPathData($data["id"]); return $this->mapper->extractUrlAliasFromData($data); }