Completed
Push — master ( 68f946...ae8931 )
by Leo
02:20
created

BlocksAdmin   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B getEditForm() 0 27 2
1
<?php
2
/**
3
 * @file BlocksAdmin.php
4
 *
5
 * Left-hand-side tab : Admin Blocks
6
 * */
7
	class BlocksAdmin extends ModelAdmin {
8
		private static $managed_models = array('Block');
9
		private static $url_segment = 'blocks';
10
		private static $menu_title = 'Blocks';
11
		private static $menu_priority = 10;
12
		private static $menu_icon = 'silverstripe-block/images/icon-block.png';
13
			
14
		public function getEditForm($id = null, $fields = null) {
15
			$form = parent::getEditForm($id, $fields);
16
			
17
			$grid = $form->Fields()->fieldByName($this->sanitiseClassName($this->modelClass));
18
			
19
			$grid->getConfig()
20
				->removeComponentsByType('GridFieldPaginator')
21
				->removeComponentsByType('GridFieldAddNewButton')
22
				->removeComponentsByType('GridFieldPrintButton')
23
				->removeComponentsByType('GridFieldExportButton')
24
				->addComponents(
25
					new GridFieldPaginatorWithShowAll(30),
26
					$multiClass = new MultiClassSelector(),
27
					$sortable = new GridFieldOrderableRows('SortOrder')
28
				);
29
			
30
			$subBlocks = ClassInfo::subclassesFor('Block');
31
			if (is_null($subBlocks)) {
32
				$subBlocks = array('Block');
33
			}else{
34
				unset($subBlocks['Block']);
35
			}
36
			
37
			$multiClass->setClasses($subBlocks);
38
			$grid->setTitle('All Blcoks');
39
			return $form;
40
		}
41
	}