Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Core/MVC/Symfony/Matcher/ContentBased/UrlAlias.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased;
8
9 use eZ\Publish\API\Repository\Values\Content\Location;
10 use eZ\Publish\API\Repository\Values\Content\ContentInfo;
11 use eZ\Publish\Core\MVC\Symfony\View\LocationValueView;
12 use eZ\Publish\Core\MVC\Symfony\View\View;
13
14 class UrlAlias extends MultipleValued
15 {
23 public function matchLocation(Location $location)
24 {
25 $urlAliasService = $this->repository->getURLAliasService();
26 $locationUrls = array_merge(
27 $urlAliasService->listLocationAliases($location),
28 $urlAliasService->listLocationAliases($location, false)
29 );
30
31 foreach ($this->values as $pattern => $val) {
32 foreach ($locationUrls as $urlAlias) {
33 if (strpos($urlAlias->path, "/$pattern") === 0) {
34 return true;
35 }
36 }
37 }
38
39 return false;
40 }
41
51 public function matchContentInfo(ContentInfo $contentInfo)
52 {
53 throw new \RuntimeException('matchContentInfo() is not supported by UrlAlias matcher');
54 }
55
56 public function setMatchingConfig($matchingConfig)
57 {
58 if (!is_array($matchingConfig)) {
59 $matchingConfig = [$matchingConfig];
60 }
61
62 array_walk(
63 $matchingConfig,
64 function (&$item) {
65 $item = trim($item, '/ ');
66 }
67 );
68
69 parent::setMatchingConfig($matchingConfig);
70 }
71
72 public function match(View $view)
73 {
74 if (!$view instanceof LocationValueView) {
75 return false;
76 }
77
78 return $this->matchLocation($view->getLocation());
79 }
80 }
eZ\Publish\API\Repository\Values\Content\ContentInfo
Definition: API/Repository/Values/Content/ContentInfo.php:31
eZ\Publish\API\Repository\Values\Content\Location
Definition: API/Repository/Values/Content/Location.php:32
eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued
Abstract class for basic matchers, accepting multiple values to match against.
Definition: ContentBased/MultipleValued.php:15
eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias
Definition: Core/MVC/Symfony/Matcher/ContentBased/UrlAlias.php:15
eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias\setMatchingConfig
setMatchingConfig($matchingConfig)
Registers the matching configuration for the matcher.
Definition: Core/MVC/Symfony/Matcher/ContentBased/UrlAlias.php:56
eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias\matchContentInfo
matchContentInfo(ContentInfo $contentInfo)
Not supported since UrlAlias is meaningful for location objects only.
Definition: Core/MVC/Symfony/Matcher/ContentBased/UrlAlias.php:51
eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias\matchLocation
matchLocation(Location $location)
Checks if a Location object matches.
Definition: Core/MVC/Symfony/Matcher/ContentBased/UrlAlias.php:23
eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias\match
match(View $view)
Matches the $view against a set of matchers.
Definition: Core/MVC/Symfony/Matcher/ContentBased/UrlAlias.php:72
eZ\Publish\Core\MVC\Symfony\View\LocationValueView
Definition: LocationValueView.php:10
eZ\Publish\Core\MVC\Symfony\View\View
Main interface for Views of Value objects (content, block...).
Definition: Publish/Core/MVC/Symfony/View/View.php:16
eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased
Definition: Core/MVC/Symfony/Matcher/ContentBased/Depth.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.