Code Duplication    Length = 5-10 lines in 4 locations

eZ/Publish/Core/Repository/ContentService.php 4 locations

@@ 1511-1517 (lines=7) @@
1508
            );
1509
        }
1510
1511
        if (!$this->repository->canUser('content', 'versionremove', $versionInfo)) {
1512
            throw new UnauthorizedException(
1513
                'content',
1514
                'versionremove',
1515
                array('contentId' => $versionInfo->contentInfo->id, 'versionNo' => $versionInfo->versionNo)
1516
            );
1517
        }
1518
1519
        $versionList = $this->persistenceHandler->contentHandler()->listVersions(
1520
            $versionInfo->contentInfo->id,
@@ 1592-1601 (lines=10) @@
1589
        $destinationLocation = $this->repository->getLocationService()->loadLocation(
1590
            $destinationLocationCreateStruct->parentLocationId
1591
        );
1592
        if (!$this->repository->canUser('content', 'create', $contentInfo, [$destinationLocation])) {
1593
            throw new UnauthorizedException(
1594
                'content',
1595
                'create',
1596
                [
1597
                    'parentLocationId' => $destinationLocationCreateStruct->parentLocationId,
1598
                    'sectionId' => $contentInfo->sectionId,
1599
                ]
1600
            );
1601
        }
1602
1603
        $defaultObjectStates = $this->getDefaultObjectStates();
1604
@@ 1904-1913 (lines=10) @@
1901
        $singleLangVersions = [];
1902
        foreach ($this->loadVersions($contentInfo) as $versionInfo) {
1903
            // check if user is authorized to delete Version
1904
            if (!$this->repository->canUser('content', 'remove', $versionInfo)) {
1905
                throw new UnauthorizedException(
1906
                    'content',
1907
                    'remove',
1908
                    [
1909
                        'contentId' => $contentInfo->id,
1910
                        'versionNo' => $versionInfo->versionNo,
1911
                    ]
1912
                );
1913
            }
1914
            // check if the specified translation exists for the Version
1915
            if (!in_array($languageCode, $versionInfo->languageCodes)) {
1916
                // if translation does not exist, simply ignore Version (see InvalidArgumentException later on)
@@ 2000-2004 (lines=5) @@
1997
            );
1998
        }
1999
2000
        if (!$this->repository->canUser('content', 'edit', $versionInfo->contentInfo)) {
2001
            throw new UnauthorizedException(
2002
                'content', 'edit', ['contentId' => $versionInfo->contentInfo->id]
2003
            );
2004
        }
2005
2006
        if (!in_array($languageCode, $versionInfo->languageCodes)) {
2007
            throw new InvalidArgumentException(