Completed
Pull Request — master (#493)
by Michael
04:02
created

DNAdmin::getEditForm()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 12

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 14
rs 9.4285
cc 2
eloc 12
nc 2
nop 2
1
<?php
2
3
class DNAdmin extends ModelAdmin {
4
5
	/**
6
	 * @var string
7
	 */
8
	public static $menu_title = "Deploynaut Projects";
9
10
	/**
11
	 * @var string
12
	 */
13
	public static $url_segment = "naut";
14
15
	/**
16
	 * @var array
17
	 */
18
	public static $managed_models = array(
19
		'DNProject' => array('title' => 'Projects'),
20
		'DNDataTransfer' => array('title' => 'Transfers'),
21
		'DNDataArchive' => array('title' => 'Archives'),
22
	);
23
24
	/**
25
	 * @var int
26
	 */
27
	private static $menu_priority = 100;
28
29
	public function getEditForm($id = null, $fields = null) {
30
		$form = parent::getEditForm($id, $fields);
31
		$gridField = $form->Fields()->dataFieldByName('DNProject');
32
		if($gridField) {
33
			$gridField->getConfig()
34
				->removeComponentsByType('GridFieldExportButton')
35
				->removeComponentsByType('GridFieldPrintButton')
36
				->removeComponentsByType('GridFieldAddNewButton')
37
				->addComponent(new GridFieldAddNewMultiClass('buttons-before-left'))
38
				->addComponent(new GridFieldExportButton('buttons-before-right'))
39
				->addComponent(new GridFieldPrintButton('buttons-before-right'));
40
		}
41
		return $form;
42
	}
43
44
}
45