Passed
Pull Request — master (#210)
by Jason
03:12
created
src/objects/Location.php 2 patches
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -28,242 +28,242 @@
 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
-        if($this->Categories()->count()) {
140
-            return implode(', ', $this->Categories()->column('Name'));
141
-        }
134
+	/**
135
+	 * @return string
136
+	 */
137
+	public function getCategoryList()
138
+	{
139
+		if($this->Categories()->count()) {
140
+			return implode(', ', $this->Categories()->column('Name'));
141
+		}
142 142
 
143
-        return '';
144
-    }
143
+		return '';
144
+	}
145 145
 
146
-    /**
147
-     * @return bool|string
148
-     */
149
-    public function getCountryCode()
150
-    {
151
-        if ($this->Country) {
152
-            return strtoupper($this->Country);
153
-        }
154
-        return false;
155
-    }
146
+	/**
147
+	 * @return bool|string
148
+	 */
149
+	public function getCountryCode()
150
+	{
151
+		if ($this->Country) {
152
+			return strtoupper($this->Country);
153
+		}
154
+		return false;
155
+	}
156 156
 
157
-    /**
158
-     * custom labels for fields
159
-     *
160
-     * @param bool $includerelations
161
-     * @return array|string
162
-     */
163
-    public function fieldLabels($includerelations = true)
164
-    {
165
-        $labels = parent::fieldLabels($includerelations);
166
-        $labels['Title'] = 'Name';
167
-        $labels['Address2'] = 'Address 2';
168
-        $labels['PostalCode'] = 'Postal Code';
169
-        $labels['Categories.Name'] = 'Categories';
170
-        $labels['Featured.NiceAsBoolean'] = 'Featured';
171
-        return $labels;
172
-    }
157
+	/**
158
+	 * custom labels for fields
159
+	 *
160
+	 * @param bool $includerelations
161
+	 * @return array|string
162
+	 */
163
+	public function fieldLabels($includerelations = true)
164
+	{
165
+		$labels = parent::fieldLabels($includerelations);
166
+		$labels['Title'] = 'Name';
167
+		$labels['Address2'] = 'Address 2';
168
+		$labels['PostalCode'] = 'Postal Code';
169
+		$labels['Categories.Name'] = 'Categories';
170
+		$labels['Featured.NiceAsBoolean'] = 'Featured';
171
+		return $labels;
172
+	}
173 173
 
174
-    /**
175
-     * @return FieldList
176
-     */
177
-    public function getCMSFields()
178
-    {
179
-        $this->beforeUpdateCMSFields(function ($fields) {
180
-            $fields->removeByName(array(
181
-                'Import_ID',
182
-                'LinkTracking',
183
-                'FileTracking',
184
-            ));
174
+	/**
175
+	 * @return FieldList
176
+	 */
177
+	public function getCMSFields()
178
+	{
179
+		$this->beforeUpdateCMSFields(function ($fields) {
180
+			$fields->removeByName(array(
181
+				'Import_ID',
182
+				'LinkTracking',
183
+				'FileTracking',
184
+			));
185 185
 
186
-            $fields->dataFieldByName('Website')
187
-                ->setAttribute('placeholder', 'http://');
186
+			$fields->dataFieldByName('Website')
187
+				->setAttribute('placeholder', 'http://');
188 188
 
189
-            $fields->replaceField('Email', EmailField::create('Email'));
189
+			$fields->replaceField('Email', EmailField::create('Email'));
190 190
 
191
-            $featured = $fields->dataFieldByName('Featured')
192
-                ->setDescription('Location will display near the top of the results list');
193
-            $fields->insertAfter(
194
-                'Fax',
195
-                $featured
196
-            );
191
+			$featured = $fields->dataFieldByName('Featured')
192
+				->setDescription('Location will display near the top of the results list');
193
+			$fields->insertAfter(
194
+				'Fax',
195
+				$featured
196
+			);
197 197
 
198
-            if ($this->ID) {
199
-                $categories = $fields->dataFieldByName('Categories');
200
-                $config = $categories->getConfig();
201
-                $config->removeComponentsByType([
202
-                    GridFieldAddExistingAutocompleter::class
203
-                ])
204
-                    ->addComponents([
205
-                        new GridFieldAddExistingSearchButton()
206
-                    ]);
207
-            }
208
-        });
198
+			if ($this->ID) {
199
+				$categories = $fields->dataFieldByName('Categories');
200
+				$config = $categories->getConfig();
201
+				$config->removeComponentsByType([
202
+					GridFieldAddExistingAutocompleter::class
203
+				])
204
+					->addComponents([
205
+						new GridFieldAddExistingSearchButton()
206
+					]);
207
+			}
208
+		});
209 209
 
210
-        $fields = parent::getCMSFields();
210
+		$fields = parent::getCMSFields();
211 211
 
212
-        // allow to be extended via DataExtension
213
-        $this->extend('updateLocationFields', $fields);
212
+		// allow to be extended via DataExtension
213
+		$this->extend('updateLocationFields', $fields);
214 214
 
215
-        return $fields;
216
-    }
215
+		return $fields;
216
+	}
217 217
 
218
-    /**
219
-     * @param null $member
220
-     * @param array $context
221
-     * @return bool
222
-     */
223
-    public function canView($member = null, $context = [])
224
-    {
225
-        return true;
226
-    }
218
+	/**
219
+	 * @param null $member
220
+	 * @param array $context
221
+	 * @return bool
222
+	 */
223
+	public function canView($member = null, $context = [])
224
+	{
225
+		return true;
226
+	}
227 227
 
228
-    /**
229
-     * @param null $member
230
-     * @param array $context
231
-     * @return bool|int
232
-     */
233
-    public function canEdit($member = null, $context = [])
234
-    {
235
-        return Permission::check('Location_EDIT', 'any', $member);
236
-    }
228
+	/**
229
+	 * @param null $member
230
+	 * @param array $context
231
+	 * @return bool|int
232
+	 */
233
+	public function canEdit($member = null, $context = [])
234
+	{
235
+		return Permission::check('Location_EDIT', 'any', $member);
236
+	}
237 237
 
238
-    /**
239
-     * @param null $member
240
-     * @param array $context
241
-     * @return bool|int
242
-     */
243
-    public function canDelete($member = null, $context = [])
244
-    {
245
-        return Permission::check('Location_DELETE', 'any', $member);
246
-    }
238
+	/**
239
+	 * @param null $member
240
+	 * @param array $context
241
+	 * @return bool|int
242
+	 */
243
+	public function canDelete($member = null, $context = [])
244
+	{
245
+		return Permission::check('Location_DELETE', 'any', $member);
246
+	}
247 247
 
248
-    /**
249
-     * @param null $member
250
-     * @param array $context
251
-     * @return bool|int
252
-     */
253
-    public function canCreate($member = null, $context = [])
254
-    {
255
-        return Permission::check('Location_CREATE', 'any', $member);
256
-    }
248
+	/**
249
+	 * @param null $member
250
+	 * @param array $context
251
+	 * @return bool|int
252
+	 */
253
+	public function canCreate($member = null, $context = [])
254
+	{
255
+		return Permission::check('Location_CREATE', 'any', $member);
256
+	}
257 257
 
258
-    /**
259
-     * @return array
260
-     */
261
-    public function providePermissions()
262
-    {
263
-        return array(
264
-            'Location_EDIT' => 'Edit a Location',
265
-            'Location_DELETE' => 'Delete a Location',
266
-            'Location_CREATE' => 'Create a Location',
267
-        );
268
-    }
258
+	/**
259
+	 * @return array
260
+	 */
261
+	public function providePermissions()
262
+	{
263
+		return array(
264
+			'Location_EDIT' => 'Edit a Location',
265
+			'Location_DELETE' => 'Delete a Location',
266
+			'Location_CREATE' => 'Create a Location',
267
+		);
268
+	}
269 269
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function getCategoryList()
138 138
     {
139
-        if($this->Categories()->count()) {
139
+        if ($this->Categories()->count()) {
140 140
             return implode(', ', $this->Categories()->column('Name'));
141 141
         }
142 142
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public function getCMSFields()
178 178
     {
179
-        $this->beforeUpdateCMSFields(function ($fields) {
179
+        $this->beforeUpdateCMSFields(function($fields) {
180 180
             $fields->removeByName(array(
181 181
                 'Import_ID',
182 182
                 'LinkTracking',
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   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 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.