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

URLHandler.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Persistence\Cache;
8
9 use eZ\Publish\API\Repository\Values\URL\URLQuery;
10 use eZ\Publish\SPI\Persistence\URL\Handler as URLHandlerInterface;
11 use eZ\Publish\SPI\Persistence\URL\URLUpdateStruct;
12
18 class URLHandler extends AbstractHandler implements URLHandlerInterface
19 {
20 private const URL_IDENTIFIER = 'url';
21 private const CONTENT_IDENTIFIER = 'content';
22
26 public function updateUrl($id, URLUpdateStruct $struct)
27 {
28 $this->logger->logCall(__METHOD__, [
29 'url' => $id,
30 'struct' => $struct,
31 ]);
32
33 $url = $this->persistenceHandler->urlHandler()->updateUrl($id, $struct);
34
35 $this->cache->invalidateTags([
36 $this->cacheIdentifierGenerator->generateTag(self::URL_IDENTIFIER, [$id]),
37 ]);
38
39 if ($struct->url !== null) {
40 $this->cache->invalidateTags(array_map(function ($id) {
41 return $this->cacheIdentifierGenerator->generateTag(self::CONTENT_IDENTIFIER, [$id]);
42 }, $this->persistenceHandler->urlHandler()->findUsages($id)));
43 }
44
45 return $url;
46 }
47
51 public function find(URLQuery $query)
52 {
53 $this->logger->logCall(__METHOD__, [
54 'query' => $query,
55 ]);
56
57 return $this->persistenceHandler->urlHandler()->find($query);
58 }
59
63 public function loadById($id)
64 {
65 $cacheItem = $this->cache->getItem(
66 $this->cacheIdentifierGenerator->generateKey(self::URL_IDENTIFIER, [$id], true)
67 );
68
69 $url = $cacheItem->get();
70 if ($cacheItem->isHit()) {
71 return $url;
72 }
73
74 $this->logger->logCall(__METHOD__, ['url' => $id]);
75 $url = $this->persistenceHandler->urlHandler()->loadById($id);
76
77 $cacheItem->set($url);
78 $cacheItem->tag([
79 $this->cacheIdentifierGenerator->generateTag(self::URL_IDENTIFIER, [$id]),
80 ]);
81 $this->cache->save($cacheItem);
82
83 return $url;
84 }
85
89 public function loadByUrl($url)
90 {
91 $this->logger->logCall(__METHOD__, ['url' => $url]);
92
93 return $this->persistenceHandler->urlHandler()->loadByUrl($url);
94 }
95
99 public function findUsages($id)
100 {
101 $this->logger->logCall(__METHOD__, ['url' => $id]);
102
103 return $this->persistenceHandler->urlHandler()->findUsages($id);
104 }
105 }
eZ\Publish\API\Repository\Values\URL\URLQuery
This class is used to perform a URL query.
Definition: URLQuery.php:15
eZ\Publish\Core\Persistence\Cache\AbstractHandler
Class AbstractHandler.
Definition: AbstractHandler.php:21
eZ\Publish\Core\Persistence\Cache\URLHandler
SPI cache for URL Handler.
Definition: URLHandler.php:19
eZ\Publish\Core\Persistence\Cache\URLHandler\URL_IDENTIFIER
const URL_IDENTIFIER
Definition: URLHandler.php:20
eZ\Publish\Core\Persistence\Cache\URLHandler\loadById
loadById($id)
{Loads the data for the URL identified by $id.\eZ\Publish\SPI\Persistence\URL\URL}
Definition: URLHandler.php:63
eZ\Publish\Core\Persistence\Cache\URLHandler\loadByUrl
loadByUrl($url)
{Loads the data for the URL identified by $url.\eZ\Publish\SPI\Persistence\URL\URL}
Definition: URLHandler.php:89
eZ\Publish\Core\Persistence\Cache\URLHandler\findUsages
findUsages($id)
{Returns IDs of Content Objects using URL identified by $id.array}
Definition: URLHandler.php:99
eZ\Publish\Core\Persistence\Cache\URLHandler\updateUrl
updateUrl($id, URLUpdateStruct $struct)
{Updates a existing URL.\eZ\Publish\SPI\Persistence\URL\URL}
Definition: URLHandler.php:26
eZ\Publish\Core\Persistence\Cache\URLHandler\CONTENT_IDENTIFIER
const CONTENT_IDENTIFIER
Definition: URLHandler.php:21
eZ\Publish\Core\Persistence\Cache\URLHandler\find
find(URLQuery $query)
{Selects URLs data using $query.array}
Definition: URLHandler.php:51
eZ\Publish\SPI\Persistence\URL\URLUpdateStruct
Definition: SPI/Persistence/URL/URLUpdateStruct.php:12
eZ\Publish\SPI\Persistence\URL\Handler
The URL Handler interface defines operations on URLs in the storage engine.
Definition: SPI/Persistence/URL/Handler.php:15
eZ\Publish\Core\Persistence\Cache
Definition: AbstractHandler.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.