Code Duplication    Length = 16-16 lines in 14 locations

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

@@ 41-56 (lines=16) @@
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function load($userId)
42
    {
43
        $cacheItem = $this->cache->getItem("ez-user-${userId}");
44
        if ($cacheItem->isHit()) {
45
            return $cacheItem->get();
46
        }
47
48
        $this->logger->logCall(__METHOD__, array('user' => $userId));
49
        $user = $this->persistenceHandler->userHandler()->load($userId);
50
51
        $cacheItem->set($user);
52
        $cacheItem->tag(['content-' . $user->id, 'user-' . $user->id]);
53
        $this->cache->save($cacheItem);
54
55
        return $user;
56
    }
57
58
    /**
59
     * {@inheritdoc}
@@ 61-76 (lines=16) @@
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function loadByLogin($login)
62
    {
63
        $cacheItem = $this->cache->getItem("ez-user-${login}-by-login");
64
        if ($cacheItem->isHit()) {
65
            return $cacheItem->get();
66
        }
67
68
        $this->logger->logCall(__METHOD__, array('user' => $login));
69
        $user = $this->persistenceHandler->userHandler()->loadByLogin($login);
70
71
        $cacheItem->set($user);
72
        $cacheItem->tag(['content-' . $user->id, 'user-' . $user->id]);
73
        $this->cache->save($cacheItem);
74
75
        return $user;
76
    }
77
78
    /**
79
     * {@inheritdoc}

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

@@ 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}
@@ 66-81 (lines=16) @@
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function loadByLanguageCode($languageCode)
67
    {
68
        $cacheItem = $this->cache->getItem('ez-language-' . $languageCode . '-by-code');
69
        if ($cacheItem->isHit()) {
70
            return $cacheItem->get();
71
        }
72
73
        $this->logger->logCall(__METHOD__, array('language' => $languageCode));
74
        $language = $this->persistenceHandler->contentLanguageHandler()->loadByLanguageCode($languageCode);
75
76
        $cacheItem->set($language);
77
        $cacheItem->tag('language-' . $language->id);
78
        $this->cache->save($cacheItem);
79
80
        return $language;
81
    }
82
83
    /**
84
     * {@inheritdoc}

eZ/Publish/Core/Persistence/Cache/ContentTypeHandler.php 4 locations

@@ 168-183 (lines=16) @@
165
    /**
166
     * {@inheritdoc}
167
     */
168
    public function loadByIdentifier($identifier)
169
    {
170
        $cacheItem = $this->cache->getItem('ez-content-type-' . $identifier . '-by-identifier');
171
        if ($cacheItem->isHit()) {
172
            return $cacheItem->get();
173
        }
174
175
        $this->logger->logCall(__METHOD__, array('type' => $identifier));
176
        $type = $this->persistenceHandler->contentTypeHandler()->loadByIdentifier($identifier);
177
178
        $cacheItem->set($type);
179
        $cacheItem->tag(['type-' . $type->id]);
180
        $this->cache->save($cacheItem);
181
182
        return $type;
183
    }
184
185
    /**
186
     * {@inheritdoc}
@@ 188-203 (lines=16) @@
185
    /**
186
     * {@inheritdoc}
187
     */
188
    public function loadByRemoteId($remoteId)
189
    {
190
        $cacheItem = $this->cache->getItem('ez-content-type-' . $remoteId . '-by-remote');
191
        if ($cacheItem->isHit()) {
192
            return $cacheItem->get();
193
        }
194
195
        $this->logger->logCall(__METHOD__, array('type' => $remoteId));
196
        $type = $this->persistenceHandler->contentTypeHandler()->loadByRemoteId($remoteId);
197
198
        $cacheItem->set($type);
199
        $cacheItem->tag(['type-' . $type->id]);
200
        $this->cache->save($cacheItem);
201
202
        return $type;
203
    }
204
205
    /**
206
     * {@inheritdoc}
@@ 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}
@@ 87-102 (lines=16) @@
84
    /**
85
     * {@inheritdoc}
86
     */
87
    public function loadGroupByIdentifier($identifier)
88
    {
89
        $cacheItem = $this->cache->getItem('ez-content-type-group-' . $identifier . '-by-identifier');
90
        if ($cacheItem->isHit()) {
91
            return $cacheItem->get();
92
        }
93
94
        $this->logger->logCall(__METHOD__, array('group' => $identifier));
95
        $group = $this->persistenceHandler->contentTypeHandler()->loadGroupByIdentifier($identifier);
96
97
        $cacheItem->set($group);
98
        $cacheItem->tag('type-group-' . $group->id);
99
        $this->cache->save($cacheItem);
100
101
        return $group;
102
    }
103
104
    /**
105
     * {@inheritdoc}

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

@@ 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}
@@ 74-89 (lines=16) @@
71
    /**
72
     * {@inheritdoc}
73
     */
74
    public function loadByIdentifier($identifier)
75
    {
76
        $cacheItem = $this->cache->getItem('ez-section-' . $identifier . '-by-identifier');
77
        if ($cacheItem->isHit()) {
78
            return $cacheItem->get();
79
        }
80
81
        $this->logger->logCall(__METHOD__, array('section' => $identifier));
82
        $section = $this->persistenceHandler->sectionHandler()->loadByIdentifier($identifier);
83
84
        $cacheItem->set($section);
85
        $cacheItem->tag(['section-' . $section->id]);
86
        $this->cache->save($cacheItem);
87
88
        return $section;
89
    }
90
91
    /**
92
     * {@inheritdoc}

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

@@ 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 3 locations

@@ 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}
@@ 55-70 (lines=16) @@
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function loadGroupByIdentifier($identifier)
56
    {
57
        $cacheItem = $this->cache->getItem('ez-state-group-' . $identifier . '-by-identifier');
58
        if ($cacheItem->isHit()) {
59
            return $cacheItem->get();
60
        }
61
62
        $this->logger->logCall(__METHOD__, array('groupId' => $identifier));
63
        $group = $this->persistenceHandler->objectStateHandler()->loadGroupByIdentifier($identifier);
64
65
        $cacheItem->set($group);
66
        $cacheItem->tag(['state-group-' . $group->id]);
67
        $this->cache->save($cacheItem);
68
69
        return $group;
70
    }
71
72
    /**
73
     * {@inheritdoc}
@@ 162-177 (lines=16) @@
159
    /**
160
     * {@inheritdoc}
161
     */
162
    public function load($stateId)
163
    {
164
        $cacheItem = $this->cache->getItem('ez-state-' . $stateId);
165
        if ($cacheItem->isHit()) {
166
            return $cacheItem->get();
167
        }
168
169
        $this->logger->logCall(__METHOD__, array('stateId' => $stateId));
170
        $objectState = $this->persistenceHandler->objectStateHandler()->load($stateId);
171
172
        $cacheItem->set($objectState);
173
        $cacheItem->tag(['state-' . $objectState->id, 'state-group-' . $objectState->groupId]);
174
        $this->cache->save($cacheItem);
175
176
        return $objectState;
177
    }
178
179
    /**
180
     * {@inheritdoc}