Code Duplication    Length = 21-22 lines in 2 locations

code/Controllers/CMSMain.php 2 locations

@@ 1698-1718 (lines=21) @@
1695
     * @return HTTPResponse
1696
     * @throws HTTPResponse_Exception
1697
     */
1698
    public function delete($data, $form)
1699
    {
1700
        $id = $data['ID'];
1701
        $record = SiteTree::get()->byID($id);
1702
        if ($record && !$record->canDelete()) {
1703
            return Security::permissionFailure();
1704
        }
1705
        if (!$record || !$record->ID) {
1706
            throw new HTTPResponse_Exception("Bad record ID #$id", 404);
1707
        }
1708
1709
        // Delete record
1710
        $record->delete();
1711
1712
        $this->getResponse()->addHeader(
1713
            'X-Status',
1714
            rawurlencode(sprintf(_t('SilverStripe\\CMS\\Controllers\\CMSMain.REMOVEDPAGEFROMDRAFT', "Removed '%s' from the draft site"), $record->Title))
1715
        );
1716
1717
        // Even if the record has been deleted from stage and live, it can be viewed in "archive mode"
1718
        return $this->getResponseNegotiator()->respond($this->getRequest());
1719
    }
1720
1721
    /**
@@ 1729-1750 (lines=22) @@
1726
     * @return HTTPResponse
1727
     * @throws HTTPResponse_Exception
1728
     */
1729
    public function archive($data, $form)
1730
    {
1731
        $id = $data['ID'];
1732
        /** @var SiteTree $record */
1733
        $record = SiteTree::get()->byID($id);
1734
        if (!$record || !$record->exists()) {
1735
            throw new HTTPResponse_Exception("Bad record ID #$id", 404);
1736
        }
1737
        if (!$record->canArchive()) {
1738
            return Security::permissionFailure();
1739
        }
1740
1741
        // Archive record
1742
        $record->doArchive();
1743
1744
        $this->getResponse()->addHeader(
1745
            'X-Status',
1746
            rawurlencode(sprintf(_t('SilverStripe\\CMS\\Controllers\\CMSMain.ARCHIVEDPAGE', "Archived page '%s'"), $record->Title))
1747
        );
1748
1749
        // Even if the record has been deleted from stage and live, it can be viewed in "archive mode"
1750
        return $this->getResponseNegotiator()->respond($this->getRequest());
1751
    }
1752
1753
    public function publish($data, $form)