@@ -57,7 +57,7 @@ |
||
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, |
@@ -66,7 +66,9 @@ discard block |
||
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 |
||
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 |
||
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; |
@@ -45,7 +45,7 @@ |
||
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)) |
@@ -45,11 +45,14 @@ |
||
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; |
@@ -51,7 +51,7 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -49,7 +49,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -92,7 +92,9 @@ |
||
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 = []; |
@@ -76,7 +76,7 @@ |
||
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(); |
@@ -81,7 +81,9 @@ |
||
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]; |
@@ -133,7 +133,7 @@ |
||
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 | } |
@@ -18,59 +18,59 @@ |
||
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 | } |
@@ -15,48 +15,48 @@ |
||
15 | 15 | */ |
16 | 16 | class DdsStorage extends \yii\db\ActiveRecord |
17 | 17 | { |
18 | - /** |
|
19 | - * @inheritdoc |
|
20 | - */ |
|
21 | - public static function tableName() |
|
22 | - { |
|
23 | - return '{{%dds_storage}}'; |
|
24 | - } |
|
18 | + /** |
|
19 | + * @inheritdoc |
|
20 | + */ |
|
21 | + public static function tableName() |
|
22 | + { |
|
23 | + return '{{%dds_storage}}'; |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * @inheritdoc |
|
28 | - */ |
|
29 | - public function rules() |
|
30 | - { |
|
31 | - return [ |
|
32 | - [['storage_ref', 'label', 'type', 'description'], 'required'], |
|
33 | - [['type'], 'string'], |
|
34 | - [['storage_ref'], 'string', 'max' => 50], |
|
35 | - [['label'], 'string', 'max' => 300], |
|
36 | - [['description'], 'string', 'max' => 8000], |
|
37 | - [['storage_ref'], 'unique'], |
|
38 | - ]; |
|
39 | - } |
|
26 | + /** |
|
27 | + * @inheritdoc |
|
28 | + */ |
|
29 | + public function rules() |
|
30 | + { |
|
31 | + return [ |
|
32 | + [['storage_ref', 'label', 'type', 'description'], 'required'], |
|
33 | + [['type'], 'string'], |
|
34 | + [['storage_ref'], 'string', 'max' => 50], |
|
35 | + [['label'], 'string', 'max' => 300], |
|
36 | + [['description'], 'string', 'max' => 8000], |
|
37 | + [['storage_ref'], 'unique'], |
|
38 | + ]; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @inheritdoc |
|
43 | - */ |
|
44 | - public function attributeLabels() |
|
45 | - { |
|
46 | - return [ |
|
47 | - 'id' => 'ID', |
|
48 | - 'storage_ref' => 'Storage Ref', |
|
49 | - 'label' => 'Label', |
|
50 | - 'type' => 'Type', |
|
51 | - 'description' => 'Description', |
|
52 | - ]; |
|
53 | - } |
|
41 | + /** |
|
42 | + * @inheritdoc |
|
43 | + */ |
|
44 | + public function attributeLabels() |
|
45 | + { |
|
46 | + return [ |
|
47 | + 'id' => 'ID', |
|
48 | + 'storage_ref' => 'Storage Ref', |
|
49 | + 'label' => 'Label', |
|
50 | + 'type' => 'Type', |
|
51 | + 'description' => 'Description', |
|
52 | + ]; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @return \yii\db\ActiveQuery |
|
57 | - */ |
|
58 | - public function getDdsDataTypes() |
|
59 | - { |
|
60 | - return $this->hasMany(DdsDataType::className(), ['storage_ref' => 'storage_ref']); |
|
61 | - } |
|
55 | + /** |
|
56 | + * @return \yii\db\ActiveQuery |
|
57 | + */ |
|
58 | + public function getDdsDataTypes() |
|
59 | + { |
|
60 | + return $this->hasMany(DdsDataType::className(), ['storage_ref' => 'storage_ref']); |
|
61 | + } |
|
62 | 62 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param array $options - additional html attribute options |
32 | 32 | * @return $this |
33 | 33 | */ |
34 | - public function setEdit($url, array $options=[]) |
|
34 | + public function setEdit($url, array $options = []) |
|
35 | 35 | { |
36 | 36 | $this->_buttons['edit'] = $options; |
37 | 37 | $this->_buttons['edit']['url'] = $url; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param array|string $url |
44 | 44 | * @param array $options - additional html attribute options |
45 | 45 | */ |
46 | - public function setDelete($url, array $options=[]) |
|
46 | + public function setDelete($url, array $options = []) |
|
47 | 47 | { |
48 | 48 | $this->_buttons['delete'] = $options; |
49 | 49 | $this->_buttons['delete']['url'] = $url; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * will append text to the CSS class e.g. btn-$type |
60 | 60 | * @param array $options - passed to Html::buttonCustom |
61 | 61 | */ |
62 | - public function addButton($key, $url, $text, $icon='', $class='', $options=[]) |
|
62 | + public function addButton($key, $url, $text, $icon = '', $class = '', $options = []) |
|
63 | 63 | { |
64 | 64 | $this->_buttons[$key] = array_merge(compact('url', 'text', 'icon', 'class'), $options); |
65 | 65 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function getWidth() |
85 | 85 | { |
86 | - return 'calc(' . (count($this->_buttons)+count($this->_actions)) . ' * ' .$this->buttonWidth . ')'; |
|
86 | + return 'calc('.(count($this->_buttons) + count($this->_actions)).' * '.$this->buttonWidth.')'; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | if (!isset($btnOps['data'])) |
98 | 98 | $btnOps['data'] = []; |
99 | 99 | if ($this->getGrid()->hasIndexColumn()) |
100 | - $btnOps['data'] = ['index' => $model[$this->getGrid()->getIndexColumn()->getKey()] ]; |
|
100 | + $btnOps['data'] = ['index' => $model[$this->getGrid()->getIndexColumn()->getKey()]]; |
|
101 | 101 | $func = 'buttonCustom'; |
102 | 102 | if ($buttonKey === 'delete') { |
103 | 103 | $func = 'buttonDelete'; |
104 | - $btnOps['data'] = Arr::merge($btnOps['data'], ['data'=> ['delete-ajax' => true ]]); |
|
104 | + $btnOps['data'] = Arr::merge($btnOps['data'], ['data'=> ['delete-ajax' => true]]); |
|
105 | 105 | } |
106 | 106 | if ($buttonKey === 'edit') { |
107 | 107 | $func = 'buttonEdit'; |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | $text = Arr::remove($btnOps, 'text', ''); |
110 | 110 | $url = Arr::remove($btnOps, 'url', ''); |
111 | 111 | $url = $this->grid->replaceRowTagsWithValues($url, $model); |
112 | - $btnOps['class'] = Arr::get($btnOps, 'class', '') . ' btn-grid'; |
|
112 | + $btnOps['class'] = Arr::get($btnOps, 'class', '').' btn-grid'; |
|
113 | 113 | $buttons[] = Html::$func($url, $text, $btnOps); |
114 | 114 | } |
115 | - return '<div class="btn-group btn-column">' . implode('', $buttons) . '</div>'; |
|
115 | + return '<div class="btn-group btn-column">'.implode('', $buttons).'</div>'; |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 |
@@ -94,10 +94,12 @@ |
||
94 | 94 | if (count($this->_buttons)) { |
95 | 95 | $buttons = []; |
96 | 96 | foreach ($this->_buttons as $buttonKey => $btnOps) { |
97 | - if (!isset($btnOps['data'])) |
|
98 | - $btnOps['data'] = []; |
|
99 | - if ($this->getGrid()->hasIndexColumn()) |
|
100 | - $btnOps['data'] = ['index' => $model[$this->getGrid()->getIndexColumn()->getKey()] ]; |
|
97 | + if (!isset($btnOps['data'])) { |
|
98 | + $btnOps['data'] = []; |
|
99 | + } |
|
100 | + if ($this->getGrid()->hasIndexColumn()) { |
|
101 | + $btnOps['data'] = ['index' => $model[$this->getGrid()->getIndexColumn()->getKey()] ]; |
|
102 | + } |
|
101 | 103 | $func = 'buttonCustom'; |
102 | 104 | if ($buttonKey === 'delete') { |
103 | 105 | $func = 'buttonDelete'; |