Code Duplication    Length = 21-22 lines in 2 locations

code/Controllers/CMSMain.php 2 locations

@@ 1270-1290 (lines=21) @@
1267
     * @return HTTPResponse
1268
     * @throws HTTPResponse_Exception
1269
     */
1270
    public function delete($data, $form)
1271
    {
1272
        $id = $data['ID'];
1273
        $record = SiteTree::get()->byID($id);
1274
        if ($record && !$record->canDelete()) {
1275
            return Security::permissionFailure();
1276
        }
1277
        if (!$record || !$record->ID) {
1278
            throw new HTTPResponse_Exception("Bad record ID #$id", 404);
1279
        }
1280
1281
        // Delete record
1282
        $record->delete();
1283
1284
        $this->getResponse()->addHeader(
1285
            'X-Status',
1286
            rawurlencode(sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT', "Removed '%s' from the draft site"), $record->Title))
1287
        );
1288
1289
        // Even if the record has been deleted from stage and live, it can be viewed in "archive mode"
1290
        return $this->getResponseNegotiator()->respond($this->getRequest());
1291
    }
1292
1293
    /**
@@ 1301-1322 (lines=22) @@
1298
     * @return HTTPResponse
1299
     * @throws HTTPResponse_Exception
1300
     */
1301
    public function archive($data, $form)
1302
    {
1303
        $id = $data['ID'];
1304
        /** @var SiteTree $record */
1305
        $record = SiteTree::get()->byID($id);
1306
        if (!$record || !$record->exists()) {
1307
            throw new HTTPResponse_Exception("Bad record ID #$id", 404);
1308
        }
1309
        if (!$record->canArchive()) {
1310
            return Security::permissionFailure();
1311
        }
1312
1313
        // Archive record
1314
        $record->doArchive();
1315
1316
        $this->getResponse()->addHeader(
1317
            'X-Status',
1318
            rawurlencode(sprintf(_t('CMSMain.ARCHIVEDPAGE', "Archived page '%s'"), $record->Title))
1319
        );
1320
1321
        // Even if the record has been deleted from stage and live, it can be viewed in "archive mode"
1322
        return $this->getResponseNegotiator()->respond($this->getRequest());
1323
    }
1324
1325
    public function publish($data, $form)