Code Duplication    Length = 21-22 lines in 2 locations

code/Controllers/CMSMain.php 2 locations

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