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

SectionHandler.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Persistence\Cache;
8
9 use eZ\Publish\SPI\Persistence\Content\Section\Handler as SectionHandlerInterface;
10
14 class SectionHandler extends AbstractHandler implements SectionHandlerInterface
15 {
16 private const SECTION_IDENTIFIER = 'section';
17 private const SECTION_WITH_BY_ID_IDENTIFIER = 'section_with_by_id';
18 private const CONTENT_IDENTIFIER = 'content';
19
23 public function create($name, $identifier)
24 {
25 $this->logger->logCall(__METHOD__, ['name' => $name, 'identifier' => $identifier]);
26
27 return $this->persistenceHandler->sectionHandler()->create($name, $identifier);
28 }
29
33 public function update($id, $name, $identifier)
34 {
35 $this->logger->logCall(__METHOD__, ['section' => $id, 'name' => $name, 'identifier' => $identifier]);
36 $section = $this->persistenceHandler->sectionHandler()->update($id, $name, $identifier);
37
38 $this->cache->invalidateTags([
39 $this->cacheIdentifierGenerator->generateTag(self::SECTION_IDENTIFIER, [$id]),
40 ]);
41
42 return $section;
43 }
44
48 public function load($id)
49 {
50 $cacheItem = $this->cache->getItem(
51 $this->cacheIdentifierGenerator->generateKey(self::SECTION_IDENTIFIER, [$id], true)
52 );
53
54 if ($cacheItem->isHit()) {
55 return $cacheItem->get();
56 }
57
58 $this->logger->logCall(__METHOD__, ['section' => $id]);
59 $section = $this->persistenceHandler->sectionHandler()->load($id);
60
61 $cacheItem->set($section);
62 $cacheItem->tag([
63 $this->cacheIdentifierGenerator->generateTag(self::SECTION_IDENTIFIER, [$section->id]),
64 ]);
65
66 $this->cache->save($cacheItem);
67
68 return $section;
69 }
70
74 public function loadAll()
75 {
76 $this->logger->logCall(__METHOD__);
77
78 return $this->persistenceHandler->sectionHandler()->loadAll();
79 }
80
84 public function loadByIdentifier($identifier)
85 {
86 $cacheItem = $this->cache->getItem(
87 $this->cacheIdentifierGenerator->generateKey(
88 self::SECTION_WITH_BY_ID_IDENTIFIER,
89 [$this->cacheIdentifierSanitizer->escapeForCacheKey($identifier)],
90 true
91 )
92 );
93
94 if ($cacheItem->isHit()) {
95 return $cacheItem->get();
96 }
97
98 $this->logger->logCall(__METHOD__, ['section' => $identifier]);
99 $section = $this->persistenceHandler->sectionHandler()->loadByIdentifier($identifier);
100
101 $cacheItem->set($section);
102 $cacheItem->tag([
103 $this->cacheIdentifierGenerator->generateTag(self::SECTION_IDENTIFIER, [$section->id]),
104 ]);
105
106 $this->cache->save($cacheItem);
107
108 return $section;
109 }
110
114 public function delete($id)
115 {
116 $this->logger->logCall(__METHOD__, ['section' => $id]);
117 $return = $this->persistenceHandler->sectionHandler()->delete($id);
118
119 $this->cache->invalidateTags([
120 $this->cacheIdentifierGenerator->generateTag(self::SECTION_IDENTIFIER, [$id]),
121 ]);
122
123 return $return;
124 }
125
129 public function assign($sectionId, $contentId)
130 {
131 $this->logger->logCall(__METHOD__, ['section' => $sectionId, 'content' => $contentId]);
132 $return = $this->persistenceHandler->sectionHandler()->assign($sectionId, $contentId);
133
134 $this->cache->invalidateTags([
135 $this->cacheIdentifierGenerator->generateTag(self::CONTENT_IDENTIFIER, [$contentId]),
136 ]);
137
138 return $return;
139 }
140
144 public function assignmentsCount($sectionId)
145 {
146 $this->logger->logCall(__METHOD__, ['section' => $sectionId]);
147
148 return $this->persistenceHandler->sectionHandler()->assignmentsCount($sectionId);
149 }
150
154 public function policiesCount($sectionId)
155 {
156 $this->logger->logCall(__METHOD__, ['section' => $sectionId]);
157
158 return $this->persistenceHandler->sectionHandler()->policiesCount($sectionId);
159 }
160
164 public function countRoleAssignmentsUsingSection($sectionId)
165 {
166 $this->logger->logCall(__METHOD__, ['section' => $sectionId]);
167
168 return $this->persistenceHandler->sectionHandler()->countRoleAssignmentsUsingSection($sectionId);
169 }
170 }
eZ\Publish\Core\Persistence\Cache\AbstractHandler
Class AbstractHandler.
Definition: AbstractHandler.php:21
eZ\Publish\Core\Persistence\Cache\SectionHandler
Definition: SectionHandler.php:15
eZ\Publish\Core\Persistence\Cache\SectionHandler\CONTENT_IDENTIFIER
const CONTENT_IDENTIFIER
Definition: SectionHandler.php:18
eZ\Publish\Core\Persistence\Cache\SectionHandler\create
create($name, $identifier)
{Create a new section.\eZ\Publish\SPI\Persistence\Content\SectionShould validate that $identifier is ...
Definition: SectionHandler.php:23
eZ\Publish\Core\Persistence\Cache\SectionHandler\assign
assign($sectionId, $contentId)
{Assigns section to single content object.}
Definition: SectionHandler.php:129
eZ\Publish\Core\Persistence\Cache\SectionHandler\loadByIdentifier
loadByIdentifier($identifier)
{Get section data by identifier.}
Definition: SectionHandler.php:84
eZ\Publish\Core\Persistence\Cache\SectionHandler\policiesCount
policiesCount($sectionId)
{Number of role policies using a Section in limitations.int}
Definition: SectionHandler.php:154
eZ\Publish\Core\Persistence\Cache\SectionHandler\SECTION_IDENTIFIER
const SECTION_IDENTIFIER
Definition: SectionHandler.php:16
eZ\Publish\Core\Persistence\Cache\SectionHandler\load
load($id)
{Get section data.}
Definition: SectionHandler.php:48
eZ\Publish\Core\Persistence\Cache\SectionHandler\SECTION_WITH_BY_ID_IDENTIFIER
const SECTION_WITH_BY_ID_IDENTIFIER
Definition: SectionHandler.php:17
eZ\Publish\Core\Persistence\Cache\SectionHandler\update
update($id, $name, $identifier)
{Update name and identifier of a section.\eZ\Publish\SPI\Persistence\Content\Section}
Definition: SectionHandler.php:33
eZ\Publish\Core\Persistence\Cache\SectionHandler\assignmentsCount
assignmentsCount($sectionId)
{Number of content assignments a Section has.int}
Definition: SectionHandler.php:144
eZ\Publish\Core\Persistence\Cache\SectionHandler\countRoleAssignmentsUsingSection
countRoleAssignmentsUsingSection($sectionId)
{Counts the number of role assignments using section with $sectionId in their limitations....
Definition: SectionHandler.php:164
eZ\Publish\Core\Persistence\Cache\SectionHandler\loadAll
loadAll()
{Get all section data.\eZ\Publish\SPI\Persistence\Content\Section[]}
Definition: SectionHandler.php:74
eZ\Publish\SPI\Persistence\Content\Section\Handler
Definition: SPI/Persistence/Content/Section/Handler.php:10
eZ\Publish\Core\Persistence\Cache
Definition: AbstractHandler.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.