Code Duplication    Length = 15-18 lines in 11 locations

eZ/Publish/Core/Persistence/Cache/ContentHandler.php 2 locations

@@ 83-97 (lines=15) @@
80
    /**
81
     * {@inheritdoc}
82
     */
83
    public function loadContentInfo($contentId)
84
    {
85
        $cacheItem = $this->cache->getItem("ez-content-info-${contentId}");
86
        if ($cacheItem->isHit()) {
87
            return $cacheItem->get();
88
        }
89
90
        $this->logger->logCall(__METHOD__, array('content' => $contentId));
91
        $contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo($contentId);
92
        $cacheItem->set($contentInfo);
93
        $cacheItem->tag($this->getCacheTags($contentInfo));
94
        $this->cache->save($cacheItem);
95
96
        return $contentInfo;
97
    }
98
99
    public function loadContentInfoList(array $contentIds)
100
    {
@@ 126-140 (lines=15) @@
123
    /**
124
     * {@inheritdoc}
125
     */
126
    public function loadContentInfoByRemoteId($remoteId)
127
    {
128
        $cacheItem = $this->cache->getItem("ez-content-info-byRemoteId-${remoteId}");
129
        if ($cacheItem->isHit()) {
130
            return $cacheItem->get();
131
        }
132
133
        $this->logger->logCall(__METHOD__, array('content' => $remoteId));
134
        $contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfoByRemoteId($remoteId);
135
        $cacheItem->set($contentInfo);
136
        $cacheItem->tag($this->getCacheTags($contentInfo));
137
        $this->cache->save($cacheItem);
138
139
        return $contentInfo;
140
    }
141
142
    /**
143
     * {@inheritdoc}

eZ/Publish/Core/Persistence/Cache/ContentLanguageHandler.php 1 location

@@ 46-61 (lines=16) @@
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function load($id)
47
    {
48
        $cacheItem = $this->cache->getItem('ez-language-' . $id);
49
        if ($cacheItem->isHit()) {
50
            return $cacheItem->get();
51
        }
52
53
        $this->logger->logCall(__METHOD__, array('language' => $id));
54
        $language = $this->persistenceHandler->contentLanguageHandler()->load($id);
55
56
        $cacheItem->set($language);
57
        $cacheItem->tag('language-' . $language->id);
58
        $this->cache->save($cacheItem);
59
60
        return $language;
61
    }
62
63
    /**
64
     * {@inheritdoc}

eZ/Publish/Core/Persistence/Cache/ContentTypeHandler.php 1 location

@@ 67-82 (lines=16) @@
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function loadGroup($groupId)
68
    {
69
        $cacheItem = $this->cache->getItem('ez-content-type-group-' . $groupId);
70
        if ($cacheItem->isHit()) {
71
            return $cacheItem->get();
72
        }
73
74
        $this->logger->logCall(__METHOD__, array('group' => $groupId));
75
        $group = $this->persistenceHandler->contentTypeHandler()->loadGroup($groupId);
76
77
        $cacheItem->set($group);
78
        $cacheItem->tag('type-group-' . $group->id);
79
        $this->cache->save($cacheItem);
80
81
        return $group;
82
    }
83
84
    /**
85
     * {@inheritdoc}

eZ/Publish/Core/Persistence/Cache/LocationHandler.php 2 locations

@@ 24-39 (lines=16) @@
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function load($locationId)
25
    {
26
        $cacheItem = $this->cache->getItem("ez-location-${locationId}");
27
        if ($cacheItem->isHit()) {
28
            return $cacheItem->get();
29
        }
30
31
        $this->logger->logCall(__METHOD__, array('location' => $locationId));
32
        $location = $this->persistenceHandler->locationHandler()->load($locationId);
33
34
        $cacheItem->set($location);
35
        $cacheItem->tag($this->getCacheTags($location));
36
        $this->cache->save($cacheItem);
37
38
        return $location;
39
    }
40
41
    /**
42
     * {@inheritdoc}
@@ 123-138 (lines=16) @@
120
    /**
121
     * {@inheritdoc}
122
     */
123
    public function loadByRemoteId($remoteId)
124
    {
125
        $cacheItem = $this->cache->getItem("ez-location-${remoteId}-by-remoteid");
126
        if ($cacheItem->isHit()) {
127
            return $cacheItem->get();
128
        }
129
130
        $this->logger->logCall(__METHOD__, array('location' => $remoteId));
131
        $location = $this->persistenceHandler->locationHandler()->loadByRemoteId($remoteId);
132
133
        $cacheItem->set($location);
134
        $cacheItem->tag($this->getCacheTags($location));
135
        $this->cache->save($cacheItem);
136
137
        return $location;
138
    }
139
140
    /**
141
     * {@inheritdoc}

eZ/Publish/Core/Persistence/Cache/ObjectStateHandler.php 1 location

@@ 35-50 (lines=16) @@
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function loadGroup($groupId)
36
    {
37
        $cacheItem = $this->cache->getItem('ez-state-group-' . $groupId);
38
        if ($cacheItem->isHit()) {
39
            return $cacheItem->get();
40
        }
41
42
        $this->logger->logCall(__METHOD__, array('groupId' => $groupId));
43
        $group = $this->persistenceHandler->objectStateHandler()->loadGroup($groupId);
44
45
        $cacheItem->set($group);
46
        $cacheItem->tag(['state-group-' . $group->id]);
47
        $this->cache->save($cacheItem);
48
49
        return $group;
50
    }
51
52
    /**
53
     * {@inheritdoc}

eZ/Publish/Core/Persistence/Cache/SectionHandler.php 1 location

@@ 44-59 (lines=16) @@
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function load($id)
45
    {
46
        $cacheItem = $this->cache->getItem('ez-section-' . $id);
47
        if ($cacheItem->isHit()) {
48
            return $cacheItem->get();
49
        }
50
51
        $this->logger->logCall(__METHOD__, array('section' => $id));
52
        $section = $this->persistenceHandler->sectionHandler()->load($id);
53
54
        $cacheItem->set($section);
55
        $cacheItem->tag(['section-' . $section->id]);
56
        $this->cache->save($cacheItem);
57
58
        return $section;
59
    }
60
61
    /**
62
     * {@inheritdoc}

eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php 1 location

@@ 211-226 (lines=16) @@
208
    /**
209
     * {@inheritdoc}
210
     */
211
    public function loadUrlAlias($id)
212
    {
213
        $cacheItem = $this->cache->getItem('ez-urlAlias-' . $id);
214
        if ($cacheItem->isHit()) {
215
            return $cacheItem->get();
216
        }
217
218
        $this->logger->logCall(__METHOD__, array('alias' => $id));
219
        $urlAlias = $this->persistenceHandler->urlAliasHandler()->loadUrlAlias($id);
220
221
        $cacheItem->set($urlAlias);
222
        $cacheItem->tag($this->getCacheTags($urlAlias));
223
        $this->cache->save($cacheItem);
224
225
        return $urlAlias;
226
    }
227
228
    /**
229
     * {@inheritdoc}

eZ/Publish/Core/Persistence/Cache/UserHandler.php 1 location

@@ 226-241 (lines=16) @@
223
    /**
224
     * {@inheritdoc}
225
     */
226
    public function loadRoleAssignment($roleAssignmentId)
227
    {
228
        $cacheItem = $this->cache->getItem("ez-role-assignment-${roleAssignmentId}");
229
        if ($cacheItem->isHit()) {
230
            return $cacheItem->get();
231
        }
232
233
        $this->logger->logCall(__METHOD__, array('assignment' => $roleAssignmentId));
234
        $roleAssignment = $this->persistenceHandler->userHandler()->loadRoleAssignment($roleAssignmentId);
235
236
        $cacheItem->set($roleAssignment);
237
        $cacheItem->tag($this->getCacheTagsForRoleAssignment($roleAssignment));
238
        $this->cache->save($cacheItem);
239
240
        return $roleAssignment;
241
    }
242
243
    /**
244
     * {@inheritdoc}

eZ/Publish/Core/Persistence/Cache/URLHandler.php 1 location

@@ 52-69 (lines=18) @@
49
    /**
50
     * {@inheritdoc}
51
     */
52
    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}