Code Duplication    Length = 10-20 lines in 9 locations

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

@@ 213-226 (lines=14) @@
210
    /**
211
     * {@inheritdoc}
212
     */
213
    public function delete($typeId, $status)
214
    {
215
        $this->logger->logCall(__METHOD__, array('type' => $typeId, 'status' => $status));
216
        $return = $this->persistenceHandler->contentTypeHandler()->delete($typeId, $status);
217
218
        if ($status === Type::STATUS_DEFINED) {
219
            // Clear type cache and all identifier cache (as we don't know the identifier)
220
            $this->cache->clear('contentType', $typeId);
221
            $this->cache->clear('contentType', 'identifier');
222
            $this->cache->clear('searchableFieldMap');
223
        }
224
225
        return $return;
226
    }
227
228
    /**
229
     * {@inheritdoc}
@@ 301-316 (lines=16) @@
298
    /**
299
     * {@inheritdoc}
300
     */
301
    public function addFieldDefinition($typeId, $status, FieldDefinition $struct)
302
    {
303
        $this->logger->logCall(__METHOD__, array('type' => $typeId, 'status' => $status, 'struct' => $struct));
304
        $return = $this->persistenceHandler->contentTypeHandler()->addFieldDefinition(
305
            $typeId,
306
            $status,
307
            $struct
308
        );
309
310
        if ($status === Type::STATUS_DEFINED) {
311
            $this->cache->clear('contentType', $typeId);
312
            $this->cache->clear('searchableFieldMap');
313
        }
314
315
        return $return;
316
    }
317
318
    /**
319
     * {@inheritdoc}
@@ 321-334 (lines=14) @@
318
    /**
319
     * {@inheritdoc}
320
     */
321
    public function removeFieldDefinition($typeId, $status, $fieldDefinitionId)
322
    {
323
        $this->logger->logCall(__METHOD__, array('type' => $typeId, 'status' => $status, 'field' => $fieldDefinitionId));
324
        $this->persistenceHandler->contentTypeHandler()->removeFieldDefinition(
325
            $typeId,
326
            $status,
327
            $fieldDefinitionId
328
        );
329
330
        if ($status === Type::STATUS_DEFINED) {
331
            $this->cache->clear('contentType', $typeId);
332
            $this->cache->clear('searchableFieldMap');
333
        }
334
    }
335
336
    /**
337
     * {@inheritdoc}
@@ 339-352 (lines=14) @@
336
    /**
337
     * {@inheritdoc}
338
     */
339
    public function updateFieldDefinition($typeId, $status, FieldDefinition $struct)
340
    {
341
        $this->logger->logCall(__METHOD__, array('type' => $typeId, 'status' => $status, 'struct' => $struct));
342
        $this->persistenceHandler->contentTypeHandler()->updateFieldDefinition(
343
            $typeId,
344
            $status,
345
            $struct
346
        );
347
348
        if ($status === Type::STATUS_DEFINED) {
349
            $this->cache->clear('contentType', $typeId);
350
            $this->cache->clear('searchableFieldMap');
351
        }
352
    }
353
354
    /**
355
     * {@inheritdoc}

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

@@ 145-156 (lines=12) @@
142
    /**
143
     * {@inheritdoc}
144
     */
145
    public function updateMetadata($contentId, MetadataUpdateStruct $struct)
146
    {
147
        $this->logger->logCall(__METHOD__, array('content' => $contentId, 'struct' => $struct));
148
149
        $this->cache
150
            ->getItem('content', 'info', $contentId)
151
            ->set($contentInfo = $this->persistenceHandler->contentHandler()->updateMetadata($contentId, $struct))->save();
152
153
        $this->cache->clear('content', $contentId, $contentInfo->currentVersionNo);
154
155
        return $contentInfo;
156
    }
157
158
    /**
159
     * {@inheritdoc}

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

@@ 36-45 (lines=10) @@
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function update($id, $name, $identifier)
37
    {
38
        $this->logger->logCall(__METHOD__, array('section' => $id, 'name' => $name, 'identifier' => $identifier));
39
        $this->cache
40
            ->getItem('section', $id)
41
            ->set($section = $this->persistenceHandler->sectionHandler()->update($id, $name, $identifier))
42
            ->save();
43
44
        return $section;
45
    }
46
47
    /**
48
     * {@inheritdoc}

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

@@ 225-236 (lines=12) @@
222
    /**
223
     * {@inheritdoc}
224
     */
225
    public function deleteRole($roleId, $status = Role::STATUS_DEFINED)
226
    {
227
        $this->logger->logCall(__METHOD__, array('role' => $roleId));
228
        $return = $this->persistenceHandler->userHandler()->deleteRole($roleId, $status);
229
230
        if ($status === Role::STATUS_DEFINED) {
231
            $this->cache->clear('user', 'role', $roleId);
232
            $this->cache->clear('user', 'role', 'assignments');
233
        }
234
235
        return $return;
236
    }
237
238
    /**
239
     * {@inheritdoc}

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

@@ 253-268 (lines=16) @@
250
    /**
251
     * {@inheritdoc}
252
     */
253
    public function locationMoved($locationId, $oldParentId, $newParentId)
254
    {
255
        $this->logger->logCall(
256
            __METHOD__,
257
            array(
258
                'location' => $locationId,
259
                'oldParent' => $oldParentId,
260
                'newParent' => $newParentId,
261
            )
262
        );
263
264
        $return = $this->persistenceHandler->urlAliasHandler()->locationMoved($locationId, $oldParentId, $newParentId);
265
        $this->cache->clear('urlAlias', 'url');//TIMBER! (Will have to load url aliases for location to be able to clear specific entries)
266
267
        return $return;
268
    }
269
270
    /**
271
     * {@inheritdoc}
@@ 273-292 (lines=20) @@
270
    /**
271
     * {@inheritdoc}
272
     */
273
    public function locationCopied($locationId, $newLocationId, $newParentId)
274
    {
275
        $this->logger->logCall(
276
            __METHOD__,
277
            array(
278
                'oldLocation' => $locationId,
279
                'newLocation' => $newLocationId,
280
                'newParent' => $newParentId,
281
            )
282
        );
283
284
        $return = $this->persistenceHandler->urlAliasHandler()->locationCopied(
285
            $locationId,
286
            $newLocationId,
287
            $newParentId
288
        );
289
        $this->cache->clear('urlAlias', 'url'); // required due to caching not found aliases
290
291
        return $return;
292
    }
293
294
    /**
295
     * {@inheritdoc}