Code Duplication    Length = 11-14 lines in 13 locations

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

@@ 48-58 (lines=11) @@
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function load($id)
49
    {
50
        $cache = $this->cache->getItem('language', $id);
51
        $language = $cache->get();
52
        if ($cache->isMiss()) {
53
            $this->logger->logCall(__METHOD__, ['language' => $id]);
54
            $cache->set($language = $this->persistenceHandler->contentLanguageHandler()->load($id))->save();
55
        }
56
57
        return $language;
58
    }
59
60
    /**
61
     * {@inheritdoc}

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

@@ 72-82 (lines=11) @@
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function loadGroup($groupId)
73
    {
74
        $cache = $this->cache->getItem('contentTypeGroup', $groupId);
75
        $group = $cache->get();
76
        if ($cache->isMiss()) {
77
            $this->logger->logCall(__METHOD__, ['group' => $groupId]);
78
            $cache->set($group = $this->persistenceHandler->contentTypeHandler()->loadGroup($groupId))->save();
79
        }
80
81
        return $group;
82
    }
83
84
    /**
85
     * {@inheritdoc}

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

@@ 24-34 (lines=11) @@
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function load($locationId)
25
    {
26
        $cache = $this->cache->getItem('location', $locationId);
27
        $location = $cache->get();
28
        if ($cache->isMiss()) {
29
            $this->logger->logCall(__METHOD__, ['location' => $locationId]);
30
            $cache->set($location = $this->persistenceHandler->locationHandler()->load($locationId))->save();
31
        }
32
33
        return $location;
34
    }
35
36
    /**
37
     * {@inheritdoc}
@@ 39-52 (lines=14) @@
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function loadSubtreeIds($locationId)
40
    {
41
        $cache = $this->cache->getItem('location', 'subtree', $locationId);
42
        $locationIds = $cache->get();
43
44
        if ($cache->isMiss()) {
45
            $this->logger->logCall(__METHOD__, ['location' => $locationId]);
46
            $cache->set(
47
                $locationIds = $this->persistenceHandler->locationHandler()->loadSubtreeIds($locationId)
48
            )->save();
49
        }
50
51
        return $locationIds;
52
    }
53
54
    /**
55
     * {@inheritdoc}

eZ/Publish/Core/Persistence/Cache/ObjectStateHandler.php 3 locations

@@ 36-46 (lines=11) @@
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function loadGroup($groupId)
37
    {
38
        $cache = $this->cache->getItem('objectstategroup', $groupId);
39
        $group = $cache->get();
40
        if ($cache->isMiss()) {
41
            $this->logger->logCall(__METHOD__, ['groupId' => $groupId]);
42
            $cache->set($group = $this->persistenceHandler->objectStateHandler()->loadGroup($groupId))->save();
43
        }
44
45
        return $group;
46
    }
47
48
    /**
49
     * {@inheritdoc}
@@ 78-89 (lines=12) @@
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function loadObjectStates($groupId)
79
    {
80
        $cache = $this->cache->getItem('objectstate', 'byGroup', $groupId);
81
        $objectStates = $cache->get();
82
        if ($cache->isMiss()) {
83
            $this->logger->logCall(__METHOD__, ['groupId' => $groupId]);
84
            $objectStates = $this->persistenceHandler->objectStateHandler()->loadObjectStates($groupId);
85
            $cache->set($objectStates)->save();
86
        }
87
88
        return $objectStates;
89
    }
90
91
    /**
92
     * {@inheritdoc}
@@ 136-146 (lines=11) @@
133
    /**
134
     * {@inheritdoc}
135
     */
136
    public function load($stateId)
137
    {
138
        $cache = $this->cache->getItem('objectstate', $stateId);
139
        $objectState = $cache->get();
140
        if ($cache->isMiss()) {
141
            $this->logger->logCall(__METHOD__, ['stateId' => $stateId]);
142
            $cache->set($objectState = $this->persistenceHandler->objectStateHandler()->load($stateId))->save();
143
        }
144
145
        return $objectState;
146
    }
147
148
    /**
149
     * {@inheritdoc}

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

@@ 50-60 (lines=11) @@
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function load($id)
51
    {
52
        $cache = $this->cache->getItem('section', $id);
53
        $section = $cache->get();
54
        if ($cache->isMiss()) {
55
            $this->logger->logCall(__METHOD__, ['section' => $id]);
56
            $cache->set($section = $this->persistenceHandler->sectionHandler()->load($id))->save();
57
        }
58
59
        return $section;
60
    }
61
62
    /**
63
     * {@inheritdoc}

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

@@ 239-251 (lines=13) @@
236
    /**
237
     * {@inheritdoc}
238
     */
239
    public function loadUrlAlias($id)
240
    {
241
        // Look for url alias cache
242
        $cache = $this->cache->getItem('urlAlias', $id);
243
        $urlAlias = $cache->get();
244
        if ($cache->isMiss()) {
245
            $this->logger->logCall(__METHOD__, ['alias' => $id]);
246
            $urlAlias = $this->persistenceHandler->urlAliasHandler()->loadUrlAlias($id);
247
            $cache->set($urlAlias)->save();
248
        }
249
250
        return $urlAlias;
251
    }
252
253
    /**
254
     * {@inheritdoc}

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

@@ 86-98 (lines=13) @@
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function loadById($id)
87
    {
88
        $cache = $this->cache->getItem('url', $id);
89
90
        $url = $cache->get();
91
        if ($cache->isMiss()) {
92
            $this->logger->logCall(__METHOD__, ['url' => $id]);
93
            $url = $this->persistenceHandler->urlHandler()->loadById($id);
94
            $cache->set($url)->save();
95
        }
96
97
        return $url;
98
    }
99
100
    /**
101
     * {@inheritdoc}
@@ 111-123 (lines=13) @@
108
    /**
109
     * {@inheritdoc}
110
     */
111
    public function findUsages($id)
112
    {
113
        $cache = $this->cache->getItem('url', $id, 'usages');
114
115
        $usages = $cache->get();
116
        if ($cache->isMiss()) {
117
            $this->logger->logCall(__METHOD__, ['url' => $id]);
118
            $usages = $this->persistenceHandler->urlHandler()->findUsages($id);
119
            $cache->set($usages)->save();
120
        }
121
122
        return $usages;
123
    }
124
}
125

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

@@ 89-99 (lines=11) @@
86
    /**
87
     * {@inheritdoc}
88
     */
89
    public function loadContentInfo($contentId)
90
    {
91
        $cache = $this->cache->getItem('content', 'info', $contentId);
92
        $contentInfo = $cache->get();
93
        if ($cache->isMiss()) {
94
            $this->logger->logCall(__METHOD__, ['content' => $contentId]);
95
            $cache->set($contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo($contentId))->save();
96
        }
97
98
        return $contentInfo;
99
    }
100
101
    public function loadContentInfoList(array $contentIds)
102
    {
@@ 110-120 (lines=11) @@
107
    /**
108
     * {@inheritdoc}
109
     */
110
    public function loadContentInfoByRemoteId($remoteId)
111
    {
112
        $cache = $this->cache->getItem('content', 'info', 'remoteId', $remoteId);
113
        $contentInfo = $cache->get();
114
        if ($cache->isMiss()) {
115
            $this->logger->logCall(__METHOD__, ['content' => $remoteId]);
116
            $cache->set($contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfoByRemoteId($remoteId))->save();
117
        }
118
119
        return $contentInfo;
120
    }
121
122
    /**
123
     * {@inheritdoc}