Passed
Push — develop ( 319bd8...330c7a )
by Neill
16:41 queued 15s
created
neon/cms/controllers/RedirectsController.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,9 +44,9 @@
 block discarded – undo
44 44
 	public function actionDelete()
45 45
 	{
46 46
 		if (!request()->isPost) abort(400, 'Must be a post method');
47
-		$url = request()->postRequired('url', );
47
+		$url = request()->postRequired('url',);
48 48
 		$redirect = CmsUrl::find()->where(['not', ['redirect' => null]])->andWhere(['url' => $url])->one();
49
-		if ($redirect===null) abort(404);
49
+		if ($redirect === null) abort(404);
50 50
 		return $redirect->delete();
51 51
 	}
52 52
 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function actionAdd()
25 25
 	{
26
-		if (!request()->isPost) abort(400, 'Must be a post method');
26
+		if (!request()->isPost) {
27
+			abort(400, 'Must be a post method');
28
+		}
27 29
 
28 30
 		$req = request()->validateData(['url' => null, 'redirect' => null], [
29 31
 			[['url', 'redirect'], 'required'],
@@ -43,10 +45,14 @@  discard block
 block discarded – undo
43 45
 
44 46
 	public function actionDelete()
45 47
 	{
46
-		if (!request()->isPost) abort(400, 'Must be a post method');
48
+		if (!request()->isPost) {
49
+			abort(400, 'Must be a post method');
50
+		}
47 51
 		$url = request()->postRequired('url', );
48 52
 		$redirect = CmsUrl::find()->where(['not', ['redirect' => null]])->andWhere(['url' => $url])->one();
49
-		if ($redirect===null) abort(404);
53
+		if ($redirect===null) {
54
+			abort(404);
55
+		}
50 56
 		return $redirect->delete();
51 57
 	}
52 58
 }
Please login to merge, or discard this patch.
neon/cms/App.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 */
211 211
 	public function getThemeAlias()
212 212
 	{
213
-		return '@root/themes/' . $this->getThemeName();
213
+		return '@root/themes/'.$this->getThemeName();
214 214
 	}
215 215
 
216 216
 	/**
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 * @inheritdoc
254 254
 	 * @unsupported - $filters is not currently supported
255 255
 	 */
256
-	public function getDataMap($key, $query='',  $filters=[], $fields=[], $start = 0, $limit = 100)
256
+	public function getDataMap($key, $query = '', $filters = [], $fields = [], $start = 0, $limit = 100)
257 257
 	{
258 258
 		if ($key === 'pages') {
259 259
 			return $this->getPagesMap($query, $filters, $fields, $start, $limit);
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
 	 */
307 307
 	public function formatPageMapResults($pages, $fields)
308 308
 	{
309
-		return collect($pages)->mapWithKeys(function ($item) use($fields) {
309
+		return collect($pages)->mapWithKeys(function($item) use($fields) {
310 310
 			if (empty($fields))
311
-				return [$item['id'] => $item['nice_id'] . ': ' . $item['title']];
311
+				return [$item['id'] => $item['nice_id'].': '.$item['title']];
312 312
 			return [$item['id'] => $item];
313 313
 		})->all();
314 314
 	}
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 	 * @param array $fields
337 337
 	 * @return array - @see $this->formatPageMapResults();
338 338
 	 */
339
-	public function getPagesMap($query=null, $filters=[], $fields=[], $start=0, $limit=100)
339
+	public function getPagesMap($query = null, $filters = [], $fields = [], $start = 0, $limit = 100)
340 340
 	{
341 341
 		$pages = CmsPage::find()
342 342
 			->select(array_merge(['id', 'nice_id', 'title'], $fields))
@@ -370,10 +370,10 @@  discard block
 block discarded – undo
370 370
 	 */
371 371
 	private function checkThemeName($name)
372 372
 	{
373
-		if ( preg_match('/[^A-Za-z0-9_-]/', $name, $matches) ) {
373
+		if (preg_match('/[^A-Za-z0-9_-]/', $name, $matches)) {
374 374
 			throw new \InvalidArgumentException("Error trying to set the theme name to '$name'"
375 375
 				."\n"."The theme name must consist of only 'a-z', '0-9', '_' and '-' characters."
376
-				."\n".'The following character is not allowed in theme names: ' . \yii\helpers\VarDumper::dumpAsString($matches[0]) );
376
+				."\n".'The following character is not allowed in theme names: '.\yii\helpers\VarDumper::dumpAsString($matches[0]));
377 377
 		}
378 378
 	}
379 379
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -155,11 +155,13 @@  discard block
 block discarded – undo
155 155
 	public function getThemeHierarchy()
156 156
 	{
157 157
 		// if we have a theme hierarchy use that
158
-		if (count($this->_themeHierarchy))
159
-			return $this->_themeHierarchy;
158
+		if (count($this->_themeHierarchy)) {
159
+					return $this->_themeHierarchy;
160
+		}
160 161
 		// otherwise drop back to the themeName
161
-		if (!empty($this->_themeName))
162
-			return [$this->_themeName];
162
+		if (!empty($this->_themeName)) {
163
+					return [$this->_themeName];
164
+		}
163 165
 		// otherwise return nothing
164 166
 		return [];
165 167
 	}
@@ -270,8 +272,9 @@  discard block
 block discarded – undo
270 272
 	 */
271 273
 	public function getMapResults($requestKey)
272 274
 	{
273
-		if (!isset($this->_mapRequestKey[$requestKey]))
274
-			throw new \InvalidArgumentException('The provided request key "'.$requestKey.'" does not exist');
275
+		if (!isset($this->_mapRequestKey[$requestKey])) {
276
+					throw new \InvalidArgumentException('The provided request key "'.$requestKey.'" does not exist');
277
+		}
275 278
 		list($key, $ids, $fields) = $this->_mapRequestKey[$requestKey];
276 279
 		if ($key === 'pages') {
277 280
 			$pages = CmsPage::find()->select(array_merge(['id', 'nice_id', 'title'], $fields))
@@ -307,8 +310,9 @@  discard block
 block discarded – undo
307 310
 	public function formatPageMapResults($pages, $fields)
308 311
 	{
309 312
 		return collect($pages)->mapWithKeys(function ($item) use($fields) {
310
-			if (empty($fields))
311
-				return [$item['id'] => $item['nice_id'] . ': ' . $item['title']];
313
+			if (empty($fields)) {
314
+							return [$item['id'] => $item['nice_id'] . ': ' . $item['title']];
315
+			}
312 316
 			return [$item['id'] => $item];
313 317
 		})->all();
314 318
 	}
Please login to merge, or discard this patch.
neon/cms/form/fields/Slug.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
 			'class' => UniqueValidator::class,
58 58
 			'targetClass'=> CmsUrl::class,
59 59
 			'targetAttribute'=>'url',
60
-		],[],'unique');
60
+		], [], 'unique');
61 61
 
62 62
 		$this->addValidator([
63 63
 			'class' => RegularExpressionValidator::class,
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -66,7 +66,9 @@  discard block
 block discarded – undo
66 66
 		]);
67 67
 
68 68
 		// assuming operation using DDS where form $name maps to dds classType
69
-		if (!$this->hasForm()) return;
69
+		if (!$this->hasForm()) {
70
+			return;
71
+		}
70 72
 		$classType = $this->getForm()->getName();
71 73
 		Event::on(DdsObjectManager::class, "dds.afterAdd.$classType", [$this, 'addCmsUrl']);
72 74
 		Event::on(DdsObjectManager::class, "dds.afterEdit.$classType", [$this, 'editCmsUrl']);
@@ -91,13 +93,19 @@  discard block
 block discarded – undo
91 93
 	 */
92 94
 	public function editCmsUrl(ObjectEditEvent $event)
93 95
 	{
94
-		if (!isset($event->object[$this->name])) return;
96
+		if (!isset($event->object[$this->name])) {
97
+			return;
98
+		}
95 99
 		$originalSlug = $event->originalValues[$this->name];
96 100
 		$newSlug = $event->object[$this->name];
97 101
 		// edit the slug in the cms_url table
98 102
 		$url = CmsUrl::findOne(['url' => $originalSlug]);
99
-		if (empty($newSlug)) return;
100
-		if ($url === null) $url = new CmsUrl();
103
+		if (empty($newSlug)) {
104
+			return;
105
+		}
106
+		if ($url === null) {
107
+			$url = new CmsUrl();
108
+		}
101 109
 		$url->url = $newSlug;
102 110
 		$url->nice_id = $this->pageId;
103 111
 		$url->save();
@@ -109,9 +117,13 @@  discard block
 block discarded – undo
109 117
 	 */
110 118
 	public function addCmsUrl(ObjectAddEvent $event)
111 119
 	{
112
-		if (!isset($event->object[$this->name])) return;
120
+		if (!isset($event->object[$this->name])) {
121
+			return;
122
+		}
113 123
 		$slug = $event->object[$this->name];
114
-		if (empty($slug)) return;
124
+		if (empty($slug)) {
125
+			return;
126
+		}
115 127
 		// add a new slug to cms url table
116 128
 		$cmsUrl = new CmsUrl();
117 129
 		$cmsUrl->url = $slug;
Please login to merge, or discard this patch.
neon/cms/form/fields/PostStats.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 	public function getValue()
46 46
 	{
47 47
 		$form = $this->getParentForm();
48
-		if ($form===null) return;
48
+		if ($form === null) return;
49 49
 		$field = $form->getField($this->linkedField);
50 50
 		$value = $field->getValue();
51 51
 		if (!is_string($value))
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,11 +45,14 @@
 block discarded – undo
45 45
 	public function getValue()
46 46
 	{
47 47
 		$form = $this->getParentForm();
48
-		if ($form===null) return;
48
+		if ($form===null) {
49
+			return;
50
+		}
49 51
 		$field = $form->getField($this->linkedField);
50 52
 		$value = $field->getValue();
51
-		if (!is_string($value))
52
-			return ['word_count'=>0, 'time_to_read'=>0];
53
+		if (!is_string($value)) {
54
+					return ['word_count'=>0, 'time_to_read'=>0];
55
+		}
53 56
 		// calculate post reading time
54 57
 		$wordCount = Str::countWords(strip_tags($value));
55 58
 		$averageWordsPerMinute = 265;
Please login to merge, or discard this patch.
neon/cms/form/Page.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 			'hint' => 'Mark the page as a collection if this page represents a resource - for example a blog post, an ecommerce product'
52 52
 		]);
53 53
 
54
-		$items = collect(neon()->getDaedalus()->getIDdsClassManagement()->listClasses(null,$total))
54
+		$items = collect(neon()->getDaedalus()->getIDdsClassManagement()->listClasses(null, $total))
55 55
 			->flatMap(function($item) { return [$item['class_type'] => $item['label']]; });
56 56
 		$this->addFieldSelect('collection_class', [
57 57
 			'label' => 'Collection Class',
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	{
127 127
 		$theme = neon()->getAlias(neon()->cms->getThemeAlias());
128 128
 		$templates = [];
129
-		foreach(File::findFiles("$theme", ['only' => ['*.tpl', '*.twig']]) as $file) {
129
+		foreach (File::findFiles("$theme", ['only' => ['*.tpl', '*.twig']]) as $file) {
130 130
 			$path = str_replace("$theme/", '', $file);
131 131
 			if (Str::startsWith($path, 'pages/') || Str::startsWith($path, 'partials/')) {
132 132
 				$templates[$path] = $path;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		// create a migration file
194 194
 		$templateFile = __DIR__.'/templates/ddsMigration.php';
195 195
 		$input = file_get_contents($templateFile);
196
-		$output = str_replace('__MIGRATION__',$this->_classname,$input);
196
+		$output = str_replace('__MIGRATION__', $this->_classname, $input);
197 197
 		file_put_contents($this->_file, $output, LOCK_EX);
198 198
 		return $this->_filename;
199 199
 
Please login to merge, or discard this patch.
neon/settings/services/SettingsManager.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @param boolean $refresh whether to refresh the cache before fetching this setting defaults to false
50 50
 	 * @return string
51 51
 	 */
52
-	public function get($app, $key, $default=null, $refresh=false)
52
+	public function get($app, $key, $default = null, $refresh = false)
53 53
 	{
54 54
 		$settings = $this->getSettings($refresh);
55 55
 		return isset($settings[$app][$key]) && $settings[$app][$key] !== '' ? $settings[$app][$key] : $default;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		$result = $setting->save();
78 78
 
79 79
 		if (!$result) {
80
-			throw new \Exception('Unable to save setting. ' . print_r($setting->getErrors(), true));
80
+			throw new \Exception('Unable to save setting. '.print_r($setting->getErrors(), true));
81 81
 		}
82 82
 		neon()->cache->delete('neon_settings');
83 83
 		$this->_settings[$app][$key] = $value;
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
 	 * @param boolean $refresh if true forces a reload of the the settings
91 91
 	 * @return array in the format @see self::$_settings
92 92
 	 */
93
-	public function getAll($refresh=false)
93
+	public function getAll($refresh = false)
94 94
 	{
95 95
 		if ($refresh) neon()->cache->delete('neon_settings');
96 96
 		return $this->_settings = neon()->cache->getOrSet('neon_settings', function() {
97 97
 			$settingRows = Setting::find()->asArray()->all();
98 98
 			$this->_settings = [];
99
-			foreach($settingRows as $setting) {
99
+			foreach ($settingRows as $setting) {
100 100
 				$this->_settings[$setting['app']][$setting['key']] = $this->_decode($setting['value']);
101 101
 			}
102 102
 			return $this->_settings;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @param boolean $refresh if true forces a reload of the the settings
110 110
 	 * @return array in the format @see self::$_settings
111 111
 	 */
112
-	public function getSettings($refresh=false)
112
+	public function getSettings($refresh = false)
113 113
 	{
114 114
 		return $this->getAll($refresh);
115 115
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,7 +92,9 @@
 block discarded – undo
92 92
 	 */
93 93
 	public function getAll($refresh=false)
94 94
 	{
95
-		if ($refresh) neon()->cache->delete('neon_settings');
95
+		if ($refresh) {
96
+			neon()->cache->delete('neon_settings');
97
+		}
96 98
 		return $this->_settings = neon()->cache->getOrSet('neon_settings', function() {
97 99
 			$settingRows = Setting::find()->asArray()->all();
98 100
 			$this->_settings = [];
Please login to merge, or discard this patch.
neon/cms/models/CmsPage.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
 	 * @throws \yii\web\HttpException
77 77
 	 * @return boolean - whether new url was saved
78 78
 	 */
79
-	public function redirect($newUrl, $createRedirect, $throw=true)
79
+	public function redirect($newUrl, $createRedirect, $throw = true)
80 80
 	{
81 81
 		// find urls that link to this page
82 82
 		$urls = CmsUrl::find()->where(['nice_id' => $this->nice_id])->limit(10)->all();
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,9 @@
 block discarded – undo
81 81
 		// find urls that link to this page
82 82
 		$urls = CmsUrl::find()->where(['nice_id' => $this->nice_id])->limit(10)->all();
83 83
 		if (count($urls) > 1) {
84
-			if ($throw) abort(400, 'There must be only one url that links to this page - otherwise the wrong url may be updated');
84
+			if ($throw) {
85
+				abort(400, 'There must be only one url that links to this page - otherwise the wrong url may be updated');
86
+			}
85 87
 			return false;
86 88
 		}
87 89
 		$url = $urls[0];
Please login to merge, or discard this patch.
neon/cms/models/CmsUrl.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@
 block discarded – undo
133 133
 	{
134 134
 		return static::cache()->getOrSet('cms_url_pages', function() {
135 135
 			return collect(CmsPage::find()->select('id, nice_id')->asArray()->all())
136
-				->flatMap(function($i){ return [$i['id'] => $i['nice_id']]; })
136
+				->flatMap(function($i) { return [$i['id'] => $i['nice_id']]; })
137 137
 				->all();
138 138
 		});
139 139
 	}
Please login to merge, or discard this patch.
neon/daedalus/services/ddsManager/models/DdsDataType.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -18,59 +18,59 @@
 block discarded – undo
18 18
  */
19 19
 class DdsDataType extends \yii\db\ActiveRecord
20 20
 {
21
-    /**
22
-     * @inheritdoc
23
-     */
24
-    public static function tableName()
25
-    {
26
-        return '{{%dds_data_type}}';
27
-    }
21
+	/**
22
+	 * @inheritdoc
23
+	 */
24
+	public static function tableName()
25
+	{
26
+		return '{{%dds_data_type}}';
27
+	}
28 28
 
29
-    /**
30
-     * @inheritdoc
31
-     */
32
-    public function rules()
33
-    {
34
-        return [
35
-            [['data_type_ref', 'storage_ref'], 'required'],
36
-            [['deleted'], 'integer'],
37
-            [['data_type_ref', 'storage_ref'], 'string', 'max' => 50],
38
-            [['label'], 'string', 'max' => 300],
39
-            [['description'], 'string', 'max' => 1000],
40
-            [['definition'], 'string', 'max' => 2000],
41
-            [['data_type_ref'], 'unique'],
42
-            [['storage_ref'], 'exist', 'skipOnError' => true, 'targetClass' => DdsStorage::className(), 'targetAttribute' => ['storage_ref' => 'storage_ref']],
43
-        ];
44
-    }
29
+	/**
30
+	 * @inheritdoc
31
+	 */
32
+	public function rules()
33
+	{
34
+		return [
35
+			[['data_type_ref', 'storage_ref'], 'required'],
36
+			[['deleted'], 'integer'],
37
+			[['data_type_ref', 'storage_ref'], 'string', 'max' => 50],
38
+			[['label'], 'string', 'max' => 300],
39
+			[['description'], 'string', 'max' => 1000],
40
+			[['definition'], 'string', 'max' => 2000],
41
+			[['data_type_ref'], 'unique'],
42
+			[['storage_ref'], 'exist', 'skipOnError' => true, 'targetClass' => DdsStorage::className(), 'targetAttribute' => ['storage_ref' => 'storage_ref']],
43
+		];
44
+	}
45 45
 
46
-    /**
47
-     * @inheritdoc
48
-     */
49
-    public function attributeLabels()
50
-    {
51
-        return [
52
-            'data_type_ref' => 'Data Type Ref',
53
-            'label' => 'Label',
54
-            'description' => 'Description',
55
-            'definition' => 'Definition',
56
-            'storage_ref' => 'Storage Ref',
57
-            'deleted' => 'Deleted',
58
-        ];
59
-    }
46
+	/**
47
+	 * @inheritdoc
48
+	 */
49
+	public function attributeLabels()
50
+	{
51
+		return [
52
+			'data_type_ref' => 'Data Type Ref',
53
+			'label' => 'Label',
54
+			'description' => 'Description',
55
+			'definition' => 'Definition',
56
+			'storage_ref' => 'Storage Ref',
57
+			'deleted' => 'Deleted',
58
+		];
59
+	}
60 60
 
61
-    /**
62
-     * @return \yii\db\ActiveQuery
63
-     */
64
-    public function getStorageRef()
65
-    {
66
-        return $this->hasOne(DdsStorage::className(), ['storage_ref' => 'storage_ref']);
67
-    }
61
+	/**
62
+	 * @return \yii\db\ActiveQuery
63
+	 */
64
+	public function getStorageRef()
65
+	{
66
+		return $this->hasOne(DdsStorage::className(), ['storage_ref' => 'storage_ref']);
67
+	}
68 68
 
69
-    /**
70
-     * @return \yii\db\ActiveQuery
71
-     */
72
-    public function getDdsMembers()
73
-    {
74
-        return $this->hasMany(DdsMember::className(), ['data_type_ref' => 'data_type_ref']);
75
-    }
69
+	/**
70
+	 * @return \yii\db\ActiveQuery
71
+	 */
72
+	public function getDdsMembers()
73
+	{
74
+		return $this->hasMany(DdsMember::className(), ['data_type_ref' => 'data_type_ref']);
75
+	}
76 76
 }
Please login to merge, or discard this patch.