Completed
Push — master ( 093a3a...44d378 )
by Leo
02:17
created

BlocksAdmin   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 36
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
A getEditForm() 0 23 1
1
<?php
2
/**
3
 * @file BlocksAdmin.php
4
 *
5
 * Left-hand-side tab : Admin Blocks
6
 * */
7
8
class BlocksAdmin extends ModelAdmin {
9
	private static $managed_models = array('Block');
1 ignored issue
show
Unused Code introduced by
The property $managed_models is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
10
	private static $url_segment = 'blocks';
1 ignored issue
show
Unused Code introduced by
The property $url_segment is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
11
	private static $menu_title = 'Blocks';
1 ignored issue
show
Unused Code introduced by
The property $menu_title is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
12
	private static $menu_priority = 10;
1 ignored issue
show
Unused Code introduced by
The property $menu_priority is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
13
	private static $menu_icon = 'silverstripe-block/images/icon-block.png';
1 ignored issue
show
Unused Code introduced by
The property $menu_icon is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
14
	
15
	public function init() {
16
		parent::init();
17
		//Requirements::javascript("silverstripe-block/js/silverstripe-block.script.js");
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
18
	}
19
	
20
	public function getEditForm($id = null, $fields = null) {
21
		$form = parent::getEditForm($id, $fields);
22
		
23
		$grid = $form->Fields()->fieldByName($this->sanitiseClassName($this->modelClass));
24
		
25
		$grid->getConfig()
26
			->removeComponentsByType('GridFieldPaginator')
27
			->removeComponentsByType('GridFieldAddNewButton')
28
			->removeComponentsByType('GridFieldPrintButton')
29
			->removeComponentsByType('GridFieldExportButton')
30
			->addComponents(
31
				new GridFieldPaginatorWithShowAll(30),
32
				$multiClass = new GridFieldAddNewMultiClass(),
33
				$sortable = new GridFieldSortableRows('SortOrder')
34
			);
35
		
36
		$subBlocks = ClassInfo::subclassesFor('Block');
37
		unset($subBlocks['Block']);
38
		
39
		$multiClass->setClasses($subBlocks);
40
		$grid->setTitle('All Blcoks');
41
		return $form;
42
	}
43
}