Code Duplication    Length = 6-14 lines in 4 locations

model/versioning/VersionedGridFieldItemRequest.php 2 locations

@@ 40-53 (lines=14) @@
37
38
        // Unpublish action
39
        $isPublished = $record->isPublished();
40
		if($isPublished && $record->canUnpublish()) {
41
			$actions->push(
42
				FormAction::create(
43
                    'doUnpublish',
44
                    _t('VersionedGridFieldItemRequest.BUTTONUNPUBLISH', 'Unpublish')
45
                )
46
                    ->setUseButtonTag(true)
47
					->setDescription(_t(
48
                        'VersionedGridFieldItemRequest.BUTTONUNPUBLISHDESC',
49
                        'Remove this record from the published site'
50
                    ))
51
					->addExtraClass('ss-ui-action-destructive')
52
			);
53
		}
54
55
        // Archive action
56
		if($record->canArchive()) {
@@ 56-69 (lines=14) @@
53
		}
54
55
        // Archive action
56
		if($record->canArchive()) {
57
            // Replace "delete" action
58
            $actions->removeByName('action_doDelete');
59
60
            // "archive"
61
            $actions->push(
62
                FormAction::create('doArchive', _t('VersionedGridFieldItemRequest.ARCHIVE','Archive'))
63
                    ->setDescription(_t(
64
                        'VersionedGridFieldItemRequest.BUTTONARCHIVEDESC',
65
                        'Unpublish and send to archive'
66
                    ))
67
                    ->addExtraClass('delete ss-ui-action-destructive')
68
            );
69
		}
70
		return $actions;
71
    }
72

admin/code/LeftAndMain.php 2 locations

@@ 1368-1373 (lines=6) @@
1365
				$actions = $record->getCMSActions();
1366
				// add default actions if none are defined
1367
				if(!$actions || !$actions->Count()) {
1368
					if($record->hasMethod('canEdit') && $record->canEdit()) {
1369
						$actions->push(
1370
							FormAction::create('save',_t('CMSMain.SAVE','Save'))
1371
								->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')
1372
						);
1373
					}
1374
					if($record->hasMethod('canDelete') && $record->canDelete()) {
1375
						$actions->push(
1376
							FormAction::create('delete',_t('ModelAdmin.DELETE','Delete'))
@@ 1374-1379 (lines=6) @@
1371
								->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')
1372
						);
1373
					}
1374
					if($record->hasMethod('canDelete') && $record->canDelete()) {
1375
						$actions->push(
1376
							FormAction::create('delete',_t('ModelAdmin.DELETE','Delete'))
1377
								->addExtraClass('ss-ui-action-destructive')
1378
						);
1379
					}
1380
				}
1381
			}
1382