Code Duplication    Length = 21-22 lines in 2 locations

code/Controllers/CMSMain.php 2 locations

@@ 1729-1749 (lines=21) @@
1726
     * @return HTTPResponse
1727
     * @throws HTTPResponse_Exception
1728
     */
1729
    public function delete($data, $form)
1730
    {
1731
        $id = $data['ID'];
1732
        $record = SiteTree::get()->byID($id);
1733
        if ($record && !$record->canDelete()) {
1734
            return Security::permissionFailure();
1735
        }
1736
        if (!$record || !$record->ID) {
1737
            throw new HTTPResponse_Exception("Bad record ID #$id", 404);
1738
        }
1739
1740
        // Delete record
1741
        $record->delete();
1742
1743
        $this->getResponse()->addHeader(
1744
            'X-Status',
1745
            rawurlencode(sprintf(_t('SilverStripe\\CMS\\Controllers\\CMSMain.REMOVEDPAGEFROMDRAFT', "Removed '%s' from the draft site"), $record->Title))
1746
        );
1747
1748
        // Even if the record has been deleted from stage and live, it can be viewed in "archive mode"
1749
        return $this->getResponseNegotiator()->respond($this->getRequest());
1750
    }
1751
1752
    /**
@@ 1760-1781 (lines=22) @@
1757
     * @return HTTPResponse
1758
     * @throws HTTPResponse_Exception
1759
     */
1760
    public function archive($data, $form)
1761
    {
1762
        $id = $data['ID'];
1763
        /** @var SiteTree $record */
1764
        $record = SiteTree::get()->byID($id);
1765
        if (!$record || !$record->exists()) {
1766
            throw new HTTPResponse_Exception("Bad record ID #$id", 404);
1767
        }
1768
        if (!$record->canArchive()) {
1769
            return Security::permissionFailure();
1770
        }
1771
1772
        // Archive record
1773
        $record->doArchive();
1774
1775
        $this->getResponse()->addHeader(
1776
            'X-Status',
1777
            rawurlencode(sprintf(_t('SilverStripe\\CMS\\Controllers\\CMSMain.ARCHIVEDPAGE', "Archived page '%s'"), $record->Title))
1778
        );
1779
1780
        // Even if the record has been deleted from stage and live, it can be viewed in "archive mode"
1781
        return $this->getResponseNegotiator()->respond($this->getRequest());
1782
    }
1783
1784
    public function publish($data, $form)