1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
5
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
6
|
|
|
*/ |
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
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* SPI cache for URL Handler. |
15
|
|
|
* |
16
|
|
|
* @see \eZ\Publish\SPI\Persistence\URL\Handler |
17
|
|
|
*/ |
18
|
|
|
class URLHandler extends AbstractHandler implements URLHandlerInterface |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* {@inheritdoc} |
22
|
|
|
*/ |
23
|
|
View Code Duplication |
public function updateUrl($id, URLUpdateStruct $struct) |
24
|
|
|
{ |
25
|
|
|
$this->logger->logCall(__METHOD__, [ |
26
|
|
|
'url' => $id, |
27
|
|
|
'struct' => $struct, |
28
|
|
|
]); |
29
|
|
|
|
30
|
|
|
$url = $this->persistenceHandler->urlHandler()->updateUrl($id, $struct); |
31
|
|
|
|
32
|
|
|
$this->cache->invalidateTags(['url-' . $id]); |
33
|
|
|
|
34
|
|
|
return $url; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
|
|
public function find(URLQuery $query) |
41
|
|
|
{ |
42
|
|
|
$this->logger->logCall(__METHOD__, [ |
43
|
|
|
'query' => $query, |
44
|
|
|
]); |
45
|
|
|
|
46
|
|
|
return $this->persistenceHandler->urlHandler()->find($query); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
|
View Code Duplication |
public function loadById($id) |
53
|
|
|
{ |
54
|
|
|
$cacheItem = $this->cache->getItem('ez-url-' . $id); |
55
|
|
|
|
56
|
|
|
$url = $cacheItem->get(); |
57
|
|
|
if ($cacheItem->isHit()) { |
58
|
|
|
return $url; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$this->logger->logCall(__METHOD__, ['url' => $id]); |
62
|
|
|
$url = $this->persistenceHandler->urlHandler()->loadById($id); |
63
|
|
|
|
64
|
|
|
$cacheItem->set($url); |
65
|
|
|
$cacheItem->tag(['url-' . $id]); |
66
|
|
|
$this->cache->save($cacheItem); |
67
|
|
|
|
68
|
|
|
return $url; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* {@inheritdoc} |
73
|
|
|
*/ |
74
|
|
|
public function loadByUrl($url) |
75
|
|
|
{ |
76
|
|
|
$this->logger->logCall(__METHOD__, ['url' => $url]); |
77
|
|
|
|
78
|
|
|
return $this->persistenceHandler->urlHandler()->loadByUrl($url); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* {@inheritdoc} |
83
|
|
|
*/ |
84
|
|
|
public function findUsages($id) |
85
|
|
|
{ |
86
|
|
|
$this->logger->logCall(__METHOD__, ['url' => $id]); |
87
|
|
|
|
88
|
|
|
return $this->persistenceHandler->urlHandler()->findUsages($id); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|