Passed
Pull Request — master (#210)
by Jason
02:49
created
src/admin/LocationAdmin.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -12,80 +12,80 @@
 block discarded – undo
12 12
 class LocationAdmin extends ModelAdmin
13 13
 {
14 14
 
15
-    /**
16
-     * @var array
17
-     */
18
-    private static $managed_models = array(
19
-        Location::class,
20
-        LocationCategory::class,
21
-    );
15
+	/**
16
+	 * @var array
17
+	 */
18
+	private static $managed_models = array(
19
+		Location::class,
20
+		LocationCategory::class,
21
+	);
22 22
 
23
-    /**
24
-     * @var array
25
-     */
26
-    private static $model_importers = array(
27
-        Location::class => LocationCsvBulkLoader::class,
28
-        LocationCategory::class => CsvBulkLoader::class,
29
-    );
23
+	/**
24
+	 * @var array
25
+	 */
26
+	private static $model_importers = array(
27
+		Location::class => LocationCsvBulkLoader::class,
28
+		LocationCategory::class => CsvBulkLoader::class,
29
+	);
30 30
 
31
-    /**
32
-     * @var string
33
-     */
34
-    private static $menu_title = 'Locator';
35
-    /**
36
-     * @var string
37
-     */
38
-    private static $url_segment = 'locator';
31
+	/**
32
+	 * @var string
33
+	 */
34
+	private static $menu_title = 'Locator';
35
+	/**
36
+	 * @var string
37
+	 */
38
+	private static $url_segment = 'locator';
39 39
 
40
-    /**
41
-     * @return array
42
-     */
43
-    public function getExportFields()
44
-    {
45
-        if ($this->modelClass == Location::class) {
46
-            $fields = [
47
-                'Title' => 'Name',
48
-                'Address' => 'Address',
49
-                'Address2' => 'Address2',
50
-                'City' => 'City',
51
-                'State' => 'State',
52
-                'PostalCode' => 'PostalCode',
53
-                'CountryCode' => 'Country',
54
-                'Phone' => 'Phone',
55
-                'Fax' => 'Fax',
56
-                'Email' => 'Email',
57
-                'Website' => 'Website',
58
-                'Featured' => 'Featured',
59
-                'CategoryList' => 'Categories',
60
-                'Lat' => 'Lat',
61
-                'Lng' => 'Lng',
62
-                'Import_ID' => 'Import_ID',
63
-            ];
64
-        }
40
+	/**
41
+	 * @return array
42
+	 */
43
+	public function getExportFields()
44
+	{
45
+		if ($this->modelClass == Location::class) {
46
+			$fields = [
47
+				'Title' => 'Name',
48
+				'Address' => 'Address',
49
+				'Address2' => 'Address2',
50
+				'City' => 'City',
51
+				'State' => 'State',
52
+				'PostalCode' => 'PostalCode',
53
+				'CountryCode' => 'Country',
54
+				'Phone' => 'Phone',
55
+				'Fax' => 'Fax',
56
+				'Email' => 'Email',
57
+				'Website' => 'Website',
58
+				'Featured' => 'Featured',
59
+				'CategoryList' => 'Categories',
60
+				'Lat' => 'Lat',
61
+				'Lng' => 'Lng',
62
+				'Import_ID' => 'Import_ID',
63
+			];
64
+		}
65 65
 
66
-        if (!isset($fields)) {
67
-            $fields = parent::getExportFields();
68
-        }
66
+		if (!isset($fields)) {
67
+			$fields = parent::getExportFields();
68
+		}
69 69
 
70
-        $this->extend('updateGetExportFields', $fields);
70
+		$this->extend('updateGetExportFields', $fields);
71 71
 
72
-        return $fields;
73
-    }
72
+		return $fields;
73
+	}
74 74
 
75
-    /**
76
-     * @param null $id
77
-     * @param null $fields
78
-     * @return $this|Form
79
-     */
80
-    public function getEditForm($id = null, $fields = null)
81
-    {
82
-        $form = parent::getEditForm($id, $fields);
83
-        $class = $this->sanitiseClassName($this->modelClass);
84
-        if ($class == Location::class) {
85
-            $gridField = $form->Fields()->fieldByName($class);
86
-            $config = $gridField->getConfig();
87
-            $config->removeComponentsByType('GridFieldDeleteAction');
88
-        }
89
-        return $form;
90
-    }
75
+	/**
76
+	 * @param null $id
77
+	 * @param null $fields
78
+	 * @return $this|Form
79
+	 */
80
+	public function getEditForm($id = null, $fields = null)
81
+	{
82
+		$form = parent::getEditForm($id, $fields);
83
+		$class = $this->sanitiseClassName($this->modelClass);
84
+		if ($class == Location::class) {
85
+			$gridField = $form->Fields()->fieldByName($class);
86
+			$config = $gridField->getConfig();
87
+			$config->removeComponentsByType('GridFieldDeleteAction');
88
+		}
89
+		return $form;
90
+	}
91 91
 }
Please login to merge, or discard this patch.
src/bulkloader/LocationCsvBulkLoader.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -13,89 +13,89 @@
 block discarded – undo
13 13
 class LocationCsvBulkLoader extends CsvBulkLoader
14 14
 {
15 15
 
16
-    /**
17
-     * @var array
18
-     */
19
-    public $columnMap = array(
20
-        'Name' => 'Title',
21
-        'EmailAddress' => 'Email',
22
-        'Categories' => '->getCategoryByName',
23
-        'Import_ID' => 'Import_ID',
24
-        'Country' => '->getCountryByName',
25
-    );
16
+	/**
17
+	 * @var array
18
+	 */
19
+	public $columnMap = array(
20
+		'Name' => 'Title',
21
+		'EmailAddress' => 'Email',
22
+		'Categories' => '->getCategoryByName',
23
+		'Import_ID' => 'Import_ID',
24
+		'Country' => '->getCountryByName',
25
+	);
26 26
 
27
-    /**
28
-     * @var array
29
-     */
30
-    public $duplicateChecks = array(
31
-        'Import_ID' => 'Import_ID'
32
-    );
27
+	/**
28
+	 * @var array
29
+	 */
30
+	public $duplicateChecks = array(
31
+		'Import_ID' => 'Import_ID'
32
+	);
33 33
 
34
-    /**
35
-     * @param $val
36
-     * @return string|string[]|null
37
-     */
38
-    public function getEscape($val)
39
-    {
40
-        return preg_replace( "/\r|\n/", "", $val );
41
-    }
34
+	/**
35
+	 * @param $val
36
+	 * @return string|string[]|null
37
+	 */
38
+	public function getEscape($val)
39
+	{
40
+		return preg_replace( "/\r|\n/", "", $val );
41
+	}
42 42
 
43
-    /**
44
-     * @param $obj
45
-     * @param $val
46
-     * @param $record
47
-     * @throws \SilverStripe\ORM\ValidationException
48
-     */
49
-    public static function getCategoryByName(&$obj, $val, $record)
50
-    {
51
-        $val = Convert::raw2sql($val);
52
-        $parts = explode(', ', $val);
43
+	/**
44
+	 * @param $obj
45
+	 * @param $val
46
+	 * @param $record
47
+	 * @throws \SilverStripe\ORM\ValidationException
48
+	 */
49
+	public static function getCategoryByName(&$obj, $val, $record)
50
+	{
51
+		$val = Convert::raw2sql($val);
52
+		$parts = explode(', ', $val);
53 53
 
54
-        foreach ($parts as $part) {
55
-            $category = LocationCategory::get()->filter(array('Name' => $part))->first();
56
-            if (!$category) {
57
-                $category = LocationCategory::create();
58
-                $category->Name = $part;
59
-                $category->write();
60
-            }
61
-            $obj->Categories()->add($category);
62
-        }
63
-    }
54
+		foreach ($parts as $part) {
55
+			$category = LocationCategory::get()->filter(array('Name' => $part))->first();
56
+			if (!$category) {
57
+				$category = LocationCategory::create();
58
+				$category->Name = $part;
59
+				$category->write();
60
+			}
61
+			$obj->Categories()->add($category);
62
+		}
63
+	}
64 64
 
65
-    /**
66
-     * @param $obj
67
-     * @param $val
68
-     * @param $record
69
-     */
70
-    public function getCountryByName(&$obj, $val, $record)
71
-    {
72
-        $val = $this->getEscape($val);
73
-        $countries = IntlLocales::singleton()->getCountries();
65
+	/**
66
+	 * @param $obj
67
+	 * @param $val
68
+	 * @param $record
69
+	 */
70
+	public function getCountryByName(&$obj, $val, $record)
71
+	{
72
+		$val = $this->getEscape($val);
73
+		$countries = IntlLocales::singleton()->getCountries();
74 74
 
75
-        if (strlen((string)$val) == 2) {
76
-            $val = strtolower($val);
77
-            if (array_key_exists($val, $countries)) {
78
-                $obj->Country = $val;
79
-            }
80
-        }
75
+		if (strlen((string)$val) == 2) {
76
+			$val = strtolower($val);
77
+			if (array_key_exists($val, $countries)) {
78
+				$obj->Country = $val;
79
+			}
80
+		}
81 81
 
82
-        if (in_array($val, $countries)) {
83
-            $obj->Country = array_search($val, $countries);
84
-        }
85
-    }
82
+		if (in_array($val, $countries)) {
83
+			$obj->Country = array_search($val, $countries);
84
+		}
85
+	}
86 86
 
87
-    /**
88
-     * @param array $record
89
-     * @param array $columnMap
90
-     * @param \SilverStripe\Dev\BulkLoader_Result $results
91
-     * @param bool $preview
92
-     * @return int|void
93
-     */
94
-    protected function processRecord($record, $columnMap, &$results, $preview = false)
95
-    {
96
-        $objID = parent::processRecord($record, $columnMap, $results, $preview = false);
87
+	/**
88
+	 * @param array $record
89
+	 * @param array $columnMap
90
+	 * @param \SilverStripe\Dev\BulkLoader_Result $results
91
+	 * @param bool $preview
92
+	 * @return int|void
93
+	 */
94
+	protected function processRecord($record, $columnMap, &$results, $preview = false)
95
+	{
96
+		$objID = parent::processRecord($record, $columnMap, $results, $preview = false);
97 97
 
98
-        $location = Location::get()->byID($objID);
99
-        $location->publishSingle();
100
-    }
98
+		$location = Location::get()->byID($objID);
99
+		$location->publishSingle();
100
+	}
101 101
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function getEscape($val)
39 39
     {
40
-        return preg_replace( "/\r|\n/", "", $val );
40
+        return preg_replace("/\r|\n/", "", $val);
41 41
     }
42 42
 
43 43
     /**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         $val = $this->getEscape($val);
73 73
         $countries = IntlLocales::singleton()->getCountries();
74 74
 
75
-        if (strlen((string)$val) == 2) {
75
+        if (strlen((string) $val) == 2) {
76 76
             $val = strtolower($val);
77 77
             if (array_key_exists($val, $countries)) {
78 78
                 $obj->Country = $val;
Please login to merge, or discard this patch.
src/objects/Location.php 1 patch
Indentation   +217 added lines, -217 removed lines patch added patch discarded remove patch
@@ -28,249 +28,249 @@
 block discarded – undo
28 28
  */
29 29
 class Location extends DataObject implements PermissionProvider
30 30
 {
31
-    /**
32
-     * @var string
33
-     */
34
-    private static $singular_name = 'Location';
31
+	/**
32
+	 * @var string
33
+	 */
34
+	private static $singular_name = 'Location';
35 35
 
36
-    /**
37
-     * @var string
38
-     */
39
-    private static $plural_name = 'Locations';
36
+	/**
37
+	 * @var string
38
+	 */
39
+	private static $plural_name = 'Locations';
40 40
 
41
-    /**
42
-     * @var array
43
-     */
44
-    private static $db = array(
45
-        'Title' => 'Varchar(255)',
46
-        'Featured' => 'Boolean',
47
-        'Website' => 'Varchar(255)',
48
-        'Phone' => 'Varchar(40)',
49
-        'Email' => 'Varchar(255)',
50
-        'Fax' => 'Varchar(45)',
51
-        'Import_ID' => 'Int',
52
-    );
41
+	/**
42
+	 * @var array
43
+	 */
44
+	private static $db = array(
45
+		'Title' => 'Varchar(255)',
46
+		'Featured' => 'Boolean',
47
+		'Website' => 'Varchar(255)',
48
+		'Phone' => 'Varchar(40)',
49
+		'Email' => 'Varchar(255)',
50
+		'Fax' => 'Varchar(45)',
51
+		'Import_ID' => 'Int',
52
+	);
53 53
 
54
-    private static $many_many = [
55
-        'Categories' => LocationCategory::class,
56
-    ];
54
+	private static $many_many = [
55
+		'Categories' => LocationCategory::class,
56
+	];
57 57
 
58
-    /**
59
-     * @var string
60
-     */
61
-    private static $table_name = 'Location';
58
+	/**
59
+	 * @var string
60
+	 */
61
+	private static $table_name = 'Location';
62 62
 
63
-    /**
64
-     * @var array
65
-     */
66
-    private static $casting = array(
67
-        'distance' => 'Decimal(9,3)',
68
-    );
63
+	/**
64
+	 * @var array
65
+	 */
66
+	private static $casting = array(
67
+		'distance' => 'Decimal(9,3)',
68
+	);
69 69
 
70
-    /**
71
-     * @var string
72
-     */
73
-    private static $default_sort = 'Title';
70
+	/**
71
+	 * @var string
72
+	 */
73
+	private static $default_sort = 'Title';
74 74
 
75
-    /**
76
-     * api access via Restful Server module
77
-     *
78
-     * @var bool
79
-     */
80
-    private static $api_access = true;
75
+	/**
76
+	 * api access via Restful Server module
77
+	 *
78
+	 * @var bool
79
+	 */
80
+	private static $api_access = true;
81 81
 
82
-    /**
83
-     * search fields for Model Admin
84
-     *
85
-     * @var array
86
-     */
87
-    private static $searchable_fields = array(
88
-        'Title',
89
-        'Address',
90
-        'City',
91
-        'State',
92
-        'PostalCode',
93
-        'Country',
94
-        'Website',
95
-        'Phone',
96
-        'Email',
97
-        'Featured',
98
-    );
82
+	/**
83
+	 * search fields for Model Admin
84
+	 *
85
+	 * @var array
86
+	 */
87
+	private static $searchable_fields = array(
88
+		'Title',
89
+		'Address',
90
+		'City',
91
+		'State',
92
+		'PostalCode',
93
+		'Country',
94
+		'Website',
95
+		'Phone',
96
+		'Email',
97
+		'Featured',
98
+	);
99 99
 
100
-    /**
101
-     * columns for grid field
102
-     *
103
-     * @var array
104
-     */
105
-    private static $summary_fields = array(
106
-        'Title',
107
-        'Address',
108
-        'Address2',
109
-        'City',
110
-        'State',
111
-        'PostalCode',
112
-        'CountryCode',
113
-        'Phone' => 'Phone',
114
-        'Fax' => 'Fax',
115
-        'Email' => 'Email',
116
-        'Website' => 'Website',
117
-        'Featured',
118
-        'CategoryList',
119
-        'Lat',
120
-        'Lng',
121
-        'Import_ID',
122
-    );
100
+	/**
101
+	 * columns for grid field
102
+	 *
103
+	 * @var array
104
+	 */
105
+	private static $summary_fields = array(
106
+		'Title',
107
+		'Address',
108
+		'Address2',
109
+		'City',
110
+		'State',
111
+		'PostalCode',
112
+		'CountryCode',
113
+		'Phone' => 'Phone',
114
+		'Fax' => 'Fax',
115
+		'Email' => 'Email',
116
+		'Website' => 'Website',
117
+		'Featured',
118
+		'CategoryList',
119
+		'Lat',
120
+		'Lng',
121
+		'Import_ID',
122
+	);
123 123
 
124
-    /**
125
-     * Coords status for $summary_fields
126
-     *
127
-     * @return string
128
-     */
129
-    public function getCoords()
130
-    {
131
-        return ($this->Lat != 0 && $this->Lng != 0) ? 'true' : 'false';
132
-    }
124
+	/**
125
+	 * Coords status for $summary_fields
126
+	 *
127
+	 * @return string
128
+	 */
129
+	public function getCoords()
130
+	{
131
+		return ($this->Lat != 0 && $this->Lng != 0) ? 'true' : 'false';
132
+	}
133 133
 
134
-    /**
135
-     * @return string
136
-     */
137
-    public function getCategoryList()
138
-    {
139
-        $list = '';
140
-        $i = 1;
134
+	/**
135
+	 * @return string
136
+	 */
137
+	public function getCategoryList()
138
+	{
139
+		$list = '';
140
+		$i = 1;
141 141
 
142
-        foreach ($this->Categories() as $category) {
143
-            $list .= $category->Name;
144
-            if ($i < $this->Categories()->count()) {
145
-                $list .= ', ';
146
-            }
147
-            $i++;
148
-        }
142
+		foreach ($this->Categories() as $category) {
143
+			$list .= $category->Name;
144
+			if ($i < $this->Categories()->count()) {
145
+				$list .= ', ';
146
+			}
147
+			$i++;
148
+		}
149 149
 
150
-        return $list;
151
-    }
150
+		return $list;
151
+	}
152 152
 
153
-    /**
154
-     * @return bool|string
155
-     */
156
-    public function getCountryCode()
157
-    {
158
-        if ($this->Country) {
159
-            return strtoupper($this->Country);
160
-        }
161
-        return false;
162
-    }
153
+	/**
154
+	 * @return bool|string
155
+	 */
156
+	public function getCountryCode()
157
+	{
158
+		if ($this->Country) {
159
+			return strtoupper($this->Country);
160
+		}
161
+		return false;
162
+	}
163 163
 
164
-    /**
165
-     * custom labels for fields
166
-     *
167
-     * @param bool $includerelations
168
-     * @return array|string
169
-     */
170
-    public function fieldLabels($includerelations = true)
171
-    {
172
-        $labels = parent::fieldLabels($includerelations);
173
-        $labels['Title'] = 'Name';
174
-        $labels['Address2'] = 'Address 2';
175
-        $labels['PostalCode'] = 'Postal Code';
176
-        $labels['Categories.Name'] = 'Categories';
177
-        $labels['Featured.NiceAsBoolean'] = 'Featured';
178
-        return $labels;
179
-    }
164
+	/**
165
+	 * custom labels for fields
166
+	 *
167
+	 * @param bool $includerelations
168
+	 * @return array|string
169
+	 */
170
+	public function fieldLabels($includerelations = true)
171
+	{
172
+		$labels = parent::fieldLabels($includerelations);
173
+		$labels['Title'] = 'Name';
174
+		$labels['Address2'] = 'Address 2';
175
+		$labels['PostalCode'] = 'Postal Code';
176
+		$labels['Categories.Name'] = 'Categories';
177
+		$labels['Featured.NiceAsBoolean'] = 'Featured';
178
+		return $labels;
179
+	}
180 180
 
181
-    /**
182
-     * @return FieldList
183
-     */
184
-    public function getCMSFields()
185
-    {
186
-        $this->beforeUpdateCMSFields(function ($fields) {
187
-            $fields->removeByName(array(
188
-                'Import_ID',
189
-                'LinkTracking',
190
-                'FileTracking',
191
-            ));
181
+	/**
182
+	 * @return FieldList
183
+	 */
184
+	public function getCMSFields()
185
+	{
186
+		$this->beforeUpdateCMSFields(function ($fields) {
187
+			$fields->removeByName(array(
188
+				'Import_ID',
189
+				'LinkTracking',
190
+				'FileTracking',
191
+			));
192 192
 
193
-            $fields->dataFieldByName('Website')
194
-                ->setAttribute('placeholder', 'http://');
193
+			$fields->dataFieldByName('Website')
194
+				->setAttribute('placeholder', 'http://');
195 195
 
196
-            $fields->replaceField('Email', EmailField::create('Email'));
196
+			$fields->replaceField('Email', EmailField::create('Email'));
197 197
 
198
-            $featured = $fields->dataFieldByName('Featured')
199
-                ->setDescription('Location will display near the top of the results list');
200
-            $fields->insertAfter(
201
-                'Fax',
202
-                $featured
203
-            );
198
+			$featured = $fields->dataFieldByName('Featured')
199
+				->setDescription('Location will display near the top of the results list');
200
+			$fields->insertAfter(
201
+				'Fax',
202
+				$featured
203
+			);
204 204
 
205
-            if ($this->ID) {
206
-                $categories = $fields->dataFieldByName('Categories');
207
-                $config = $categories->getConfig();
208
-                $config->removeComponentsByType([
209
-                    GridFieldAddExistingAutocompleter::class
210
-                ])
211
-                    ->addComponents([
212
-                        new GridFieldAddExistingSearchButton()
213
-                    ]);
214
-            }
215
-        });
205
+			if ($this->ID) {
206
+				$categories = $fields->dataFieldByName('Categories');
207
+				$config = $categories->getConfig();
208
+				$config->removeComponentsByType([
209
+					GridFieldAddExistingAutocompleter::class
210
+				])
211
+					->addComponents([
212
+						new GridFieldAddExistingSearchButton()
213
+					]);
214
+			}
215
+		});
216 216
 
217
-        $fields = parent::getCMSFields();
217
+		$fields = parent::getCMSFields();
218 218
 
219
-        // allow to be extended via DataExtension
220
-        $this->extend('updateLocationFields', $fields);
219
+		// allow to be extended via DataExtension
220
+		$this->extend('updateLocationFields', $fields);
221 221
 
222
-        return $fields;
223
-    }
222
+		return $fields;
223
+	}
224 224
 
225
-    /**
226
-     * @param null $member
227
-     * @param array $context
228
-     * @return bool
229
-     */
230
-    public function canView($member = null, $context = [])
231
-    {
232
-        return true;
233
-    }
225
+	/**
226
+	 * @param null $member
227
+	 * @param array $context
228
+	 * @return bool
229
+	 */
230
+	public function canView($member = null, $context = [])
231
+	{
232
+		return true;
233
+	}
234 234
 
235
-    /**
236
-     * @param null $member
237
-     * @param array $context
238
-     * @return bool|int
239
-     */
240
-    public function canEdit($member = null, $context = [])
241
-    {
242
-        return Permission::check('Location_EDIT', 'any', $member);
243
-    }
235
+	/**
236
+	 * @param null $member
237
+	 * @param array $context
238
+	 * @return bool|int
239
+	 */
240
+	public function canEdit($member = null, $context = [])
241
+	{
242
+		return Permission::check('Location_EDIT', 'any', $member);
243
+	}
244 244
 
245
-    /**
246
-     * @param null $member
247
-     * @param array $context
248
-     * @return bool|int
249
-     */
250
-    public function canDelete($member = null, $context = [])
251
-    {
252
-        return Permission::check('Location_DELETE', 'any', $member);
253
-    }
245
+	/**
246
+	 * @param null $member
247
+	 * @param array $context
248
+	 * @return bool|int
249
+	 */
250
+	public function canDelete($member = null, $context = [])
251
+	{
252
+		return Permission::check('Location_DELETE', 'any', $member);
253
+	}
254 254
 
255
-    /**
256
-     * @param null $member
257
-     * @param array $context
258
-     * @return bool|int
259
-     */
260
-    public function canCreate($member = null, $context = [])
261
-    {
262
-        return Permission::check('Location_CREATE', 'any', $member);
263
-    }
255
+	/**
256
+	 * @param null $member
257
+	 * @param array $context
258
+	 * @return bool|int
259
+	 */
260
+	public function canCreate($member = null, $context = [])
261
+	{
262
+		return Permission::check('Location_CREATE', 'any', $member);
263
+	}
264 264
 
265
-    /**
266
-     * @return array
267
-     */
268
-    public function providePermissions()
269
-    {
270
-        return array(
271
-            'Location_EDIT' => 'Edit a Location',
272
-            'Location_DELETE' => 'Delete a Location',
273
-            'Location_CREATE' => 'Create a Location',
274
-        );
275
-    }
265
+	/**
266
+	 * @return array
267
+	 */
268
+	public function providePermissions()
269
+	{
270
+		return array(
271
+			'Location_EDIT' => 'Edit a Location',
272
+			'Location_DELETE' => 'Delete a Location',
273
+			'Location_CREATE' => 'Create a Location',
274
+		);
275
+	}
276 276
 }
Please login to merge, or discard this patch.
src/objects/LocationCategory.php 1 patch
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -20,125 +20,125 @@
 block discarded – undo
20 20
  */
21 21
 class LocationCategory extends DataObject
22 22
 {
23
-    /**
24
-     * @var string
25
-     */
26
-    private static $singular_name = 'Category';
27
-
28
-    /**
29
-     * @var string
30
-     */
31
-    private static $plural_name = 'Categories';
32
-
33
-    /**
34
-     * @var array
35
-     */
36
-    private static $db = array(
37
-        'Name' => 'Varchar(100)',
38
-    );
39
-
40
-    /**
41
-     * @var array
42
-     */
43
-    private static $belongs_many_many = array(
44
-        'Locators' => Locator::class,
45
-        'LocationSet' => Location::class,
46
-    );
47
-
48
-    /**
49
-     * @var string
50
-     */
51
-    private static $table_name = 'LocationCategory';
52
-
53
-    /**
54
-     * @var string
55
-     */
56
-    private static $default_sort = 'Name';
57
-
58
-    /**
59
-     * @return \SilverStripe\Forms\FieldList
60
-     */
61
-    public function getCMSFields()
62
-    {
63
-        $this->beforeUpdateCMSFields(function ($fields) {
64
-            $fields->removeByName([
65
-                'Locations',
66
-                'LocationSet',
67
-                'Locators',
68
-                'LinkTracking',
69
-                'FileTracking',
70
-            ]);
71
-
72
-            if ($this->ID) {
73
-                // Locations
74
-                $config = GridFieldConfig_RelationEditor::create();
75
-                $config->removeComponentsByType([
76
-                    GridFieldAddExistingAutocompleter::class,
77
-                    GridFieldAddNewButton::class
78
-                ])
79
-                    ->addComponents([
80
-                        new GridFieldAddExistingSearchButton(),
81
-                    ]);
82
-                $locations = $this->Locations();
83
-                $locationField = GridField::create('Locations', 'Locations', $locations, $config);
84
-
85
-                $fields->addFieldsToTab('Root.Main', array(
86
-                    $locationField,
87
-                ));
88
-            }
89
-        });
90
-
91
-        $fields = parent::getCMSFields();
92
-
93
-        return $fields;
94
-    }
95
-
96
-    /**
97
-     * For backwards compatability
98
-     * @return Locations|ManyManyList
99
-     */
100
-    public function Locations()
101
-    {
102
-        return $this->LocationSet();
103
-    }
104
-
105
-    /**
106
-     * @param null $member
107
-     * @param array $context
108
-     * @return bool
109
-     */
110
-    public function canView($member = null, $context = [])
111
-    {
112
-        return true;
113
-    }
114
-
115
-    /**
116
-     * @param null $member
117
-     * @param array $context
118
-     * @return bool|int
119
-     */
120
-    public function canEdit($member = null, $context = [])
121
-    {
122
-        return Permission::check('Location_EDIT', 'any', $member);
123
-    }
124
-
125
-    /**
126
-     * @param null $member
127
-     * @param array $context
128
-     * @return bool|int
129
-     */
130
-    public function canDelete($member = null, $context = [])
131
-    {
132
-        return Permission::check('Location_DELETE', 'any', $member);
133
-    }
134
-
135
-    /**
136
-     * @param null $member
137
-     * @param array $context
138
-     * @return bool|int
139
-     */
140
-    public function canCreate($member = null, $context = [])
141
-    {
142
-        return Permission::check('Location_CREATE', 'any', $member);
143
-    }
23
+	/**
24
+	 * @var string
25
+	 */
26
+	private static $singular_name = 'Category';
27
+
28
+	/**
29
+	 * @var string
30
+	 */
31
+	private static $plural_name = 'Categories';
32
+
33
+	/**
34
+	 * @var array
35
+	 */
36
+	private static $db = array(
37
+		'Name' => 'Varchar(100)',
38
+	);
39
+
40
+	/**
41
+	 * @var array
42
+	 */
43
+	private static $belongs_many_many = array(
44
+		'Locators' => Locator::class,
45
+		'LocationSet' => Location::class,
46
+	);
47
+
48
+	/**
49
+	 * @var string
50
+	 */
51
+	private static $table_name = 'LocationCategory';
52
+
53
+	/**
54
+	 * @var string
55
+	 */
56
+	private static $default_sort = 'Name';
57
+
58
+	/**
59
+	 * @return \SilverStripe\Forms\FieldList
60
+	 */
61
+	public function getCMSFields()
62
+	{
63
+		$this->beforeUpdateCMSFields(function ($fields) {
64
+			$fields->removeByName([
65
+				'Locations',
66
+				'LocationSet',
67
+				'Locators',
68
+				'LinkTracking',
69
+				'FileTracking',
70
+			]);
71
+
72
+			if ($this->ID) {
73
+				// Locations
74
+				$config = GridFieldConfig_RelationEditor::create();
75
+				$config->removeComponentsByType([
76
+					GridFieldAddExistingAutocompleter::class,
77
+					GridFieldAddNewButton::class
78
+				])
79
+					->addComponents([
80
+						new GridFieldAddExistingSearchButton(),
81
+					]);
82
+				$locations = $this->Locations();
83
+				$locationField = GridField::create('Locations', 'Locations', $locations, $config);
84
+
85
+				$fields->addFieldsToTab('Root.Main', array(
86
+					$locationField,
87
+				));
88
+			}
89
+		});
90
+
91
+		$fields = parent::getCMSFields();
92
+
93
+		return $fields;
94
+	}
95
+
96
+	/**
97
+	 * For backwards compatability
98
+	 * @return Locations|ManyManyList
99
+	 */
100
+	public function Locations()
101
+	{
102
+		return $this->LocationSet();
103
+	}
104
+
105
+	/**
106
+	 * @param null $member
107
+	 * @param array $context
108
+	 * @return bool
109
+	 */
110
+	public function canView($member = null, $context = [])
111
+	{
112
+		return true;
113
+	}
114
+
115
+	/**
116
+	 * @param null $member
117
+	 * @param array $context
118
+	 * @return bool|int
119
+	 */
120
+	public function canEdit($member = null, $context = [])
121
+	{
122
+		return Permission::check('Location_EDIT', 'any', $member);
123
+	}
124
+
125
+	/**
126
+	 * @param null $member
127
+	 * @param array $context
128
+	 * @return bool|int
129
+	 */
130
+	public function canDelete($member = null, $context = [])
131
+	{
132
+		return Permission::check('Location_DELETE', 'any', $member);
133
+	}
134
+
135
+	/**
136
+	 * @param null $member
137
+	 * @param array $context
138
+	 * @return bool|int
139
+	 */
140
+	public function canCreate($member = null, $context = [])
141
+	{
142
+		return Permission::check('Location_CREATE', 'any', $member);
143
+	}
144 144
 }
Please login to merge, or discard this patch.