Completed
Push — master ( ae8931...2d50a9 )
by Leo
02:38
created

SHBlocksAdmin::getEditForm()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 27
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
rs 8.8571
cc 2
eloc 20
nc 2
nop 2
1
<?php
2
/**
3
 * @file BlocksAdmin.php
4
 *
5
 * Left-hand-side tab : Admin Blocks
6
 * */
7
	class SHBlocksAdmin extends ModelAdmin {
8
		private static $managed_models = array('SHBlock');
9
		private static $url_segment = 'sh-blocks';
10
		private static $menu_title = 'SH 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('SHBlock');
31
			if (is_null($subBlocks)) {
32
				$subBlocks = array('SHBlock');
33
			}else{
34
				unset($subBlocks['SHBlock']);
35
			}
36
			
37
			$multiClass->setClasses($subBlocks);
38
			$grid->setTitle('All Blcoks');
39
			return $form;
40
		}
41
	}