@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | |
8 | 8 | class m170112_211700_change_dds_page_ids_to_uuid64 extends Migration |
9 | 9 | { |
10 | - public function safeUp() |
|
11 | - { |
|
12 | - $cms_page = CmsPage::tableName(); |
|
13 | - // Step 1 |
|
10 | + public function safeUp() |
|
11 | + { |
|
12 | + $cms_page = CmsPage::tableName(); |
|
13 | + // Step 1 |
|
14 | 14 | // ------ |
15 | - // loop through all members in the DDS and find all members with a definition using |
|
15 | + // loop through all members in the DDS and find all members with a definition using |
|
16 | 16 | // {class: neon\\cms\\form\\fields\\PageSelector} |
17 | 17 | // or where the definition uses a `dataMapKey` of `pages` and a `dataMapProvider` of `cms` |
18 | 18 | $members = neon()->db->query()->select('*')->from('dds_member')->where('definition LIKE \'{"class":"neon__cms__form__fields__PageSelector%\'')->all(); |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | } |
48 | 48 | } |
49 | 49 | $this->dropColumn($cms_page, 'old_id'); |
50 | - } |
|
50 | + } |
|
51 | 51 | |
52 | - public function safeDown() |
|
53 | - { |
|
54 | - echo "There is no coming back from this!\n"; |
|
55 | - } |
|
52 | + public function safeDown() |
|
53 | + { |
|
54 | + echo "There is no coming back from this!\n"; |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | \ No newline at end of file |
@@ -27,14 +27,14 @@ |
||
27 | 27 | // - note the `member_ref` as the $column in the ddt table - this column will hold the previous integer based page id |
28 | 28 | // which will match the cms_page.old_id column |
29 | 29 | foreach ($members as $member) { |
30 | - $class_type = $member['class_type']; |
|
31 | - $ddt_table_name = 'ddt_' . $class_type; |
|
30 | + $class_type = $member['class_type']; |
|
31 | + $ddt_table_name = 'ddt_'.$class_type; |
|
32 | 32 | $column = $member['member_ref']; |
33 | 33 | |
34 | 34 | // Step 3 |
35 | 35 | // ------ |
36 | 36 | // Alter the $column in $ddt_table_name to be a uuid64 (char(22)) |
37 | - $exists = $this->db->createCommand("SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE `table_name` = '$ddt_table_name' AND `table_schema` = '". env('DB_NAME')."' AND column_name = '$column'")->queryScalar(); |
|
37 | + $exists = $this->db->createCommand("SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE `table_name` = '$ddt_table_name' AND `table_schema` = '".env('DB_NAME')."' AND column_name = '$column'")->queryScalar(); |
|
38 | 38 | if ($exists) { |
39 | 39 | $this->alterColumn($ddt_table_name, $column, $this->char(22)->comment("A uuid using base 64")); |
40 | 40 | // Update the $column value in every row in the $ddt_table_name by matching it to the cms_page.old_id |
@@ -27,7 +27,7 @@ |
||
27 | 27 | 'layout' => 'string COMMENT "the name of the layout template to load for this page"', |
28 | 28 | 'template' => 'string COMMENT "the name of the template file"' |
29 | 29 | ]); |
30 | - $this->createTable(CmsUrl::tableName(),[ |
|
30 | + $this->createTable(CmsUrl::tableName(), [ |
|
31 | 31 | 'id' => 'pk', |
32 | 32 | 'url' => 'string', |
33 | 33 | 'page_id' => 'int', |
@@ -10,7 +10,7 @@ |
||
10 | 10 | // created by an earlier cms migration so always appears if the |
11 | 11 | // migration creation order is not adhered to. |
12 | 12 | $connection = neon()->db; |
13 | -$sql =<<<EOQ |
|
13 | +$sql = <<<EOQ |
|
14 | 14 | SET foreign_key_checks = 0; |
15 | 15 | DROP TABLE IF EXISTS `ddt_cms_static_content`; |
16 | 16 | DELETE FROM `dds_member` WHERE `class_type`='cms_static_content'; |
@@ -7,23 +7,23 @@ |
||
7 | 7 | |
8 | 8 | class m170112_201653_cms_static_content_page_ids_to_uuid64 extends Migration |
9 | 9 | { |
10 | - public function safeUp() |
|
11 | - { |
|
12 | - $cms_static_content = CmsStaticContent::tableName(); |
|
10 | + public function safeUp() |
|
11 | + { |
|
12 | + $cms_static_content = CmsStaticContent::tableName(); |
|
13 | 13 | $cms_page = CmsPage::tableName(); |
14 | 14 | |
15 | 15 | // use a nice id |
16 | - $this->alterColumn($cms_static_content, 'page_id', $this->char(22)->null()->comment('A uuid using base 64')); |
|
16 | + $this->alterColumn($cms_static_content, 'page_id', $this->char(22)->null()->comment('A uuid using base 64')); |
|
17 | 17 | // update with nice_id's |
18 | 18 | $this->execute("UPDATE $cms_static_content JOIN $cms_page ON $cms_page.old_id = $cms_static_content.page_id SET $cms_static_content.page_id = $cms_page.id"); |
19 | - } |
|
19 | + } |
|
20 | 20 | |
21 | - public function safeDown() |
|
22 | - { |
|
21 | + public function safeDown() |
|
22 | + { |
|
23 | 23 | $cms_static_content = CmsStaticContent::tableName(); |
24 | 24 | $cms_page = CmsPage::tableName(); |
25 | 25 | |
26 | 26 | $this->execute("UPDATE $cms_static_content JOIN $cms_page ON $cms_page.id = $cms_static_content.page_id SET $cms_static_content.page_id = $cms_page.old_id"); |
27 | 27 | $this->alterColumn($cms_static_content, 'page_id', $this->integer(11)->null()); |
28 | - } |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -5,20 +5,20 @@ |
||
5 | 5 | class m161130_180814_cms_additional_page_fields extends Migration |
6 | 6 | { |
7 | 7 | |
8 | - public function safeUp() |
|
9 | - { |
|
8 | + public function safeUp() |
|
9 | + { |
|
10 | 10 | $this->addColumn('cms_page', 'keywords', "VARCHAR(1000) NULL COMMENT 'Keywords for this page'"); |
11 | 11 | $this->addColumn('cms_page', 'description', "VARCHAR(1000) NULL COMMENT 'Description of this page'"); |
12 | 12 | $this->addColumn('cms_page', 'languages', "VARCHAR(1000) NULL COMMENT 'Supported languages on this page'"); |
13 | 13 | $this->addColumn('cms_page', 'page_params', "VARCHAR(10000) NULL COMMENT 'Additional parameters for this page which are interpreted directly within the templates'"); |
14 | - } |
|
14 | + } |
|
15 | 15 | |
16 | - public function safeDown() |
|
17 | - { |
|
16 | + public function safeDown() |
|
17 | + { |
|
18 | 18 | $this->dropColumn('cms_page', 'keywords'); |
19 | 19 | $this->dropColumn('cms_page', 'description'); |
20 | 20 | $this->dropColumn('cms_page', 'languages'); |
21 | 21 | $this->dropColumn('cms_page', 'page_params'); |
22 | - } |
|
22 | + } |
|
23 | 23 | |
24 | 24 | } |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | |
5 | 5 | class m170107_201653_cms_create_cms_static_content_table_again extends Migration |
6 | 6 | { |
7 | - public function safeUp() |
|
8 | - { |
|
7 | + public function safeUp() |
|
8 | + { |
|
9 | 9 | $cms_static = 'cms_static_content'; |
10 | 10 | |
11 | 11 | // recreate the table with the new structure |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | // } |
47 | 47 | // } |
48 | 48 | // } while ($count < $total); |
49 | - } |
|
49 | + } |
|
50 | 50 | |
51 | - public function safeDown() |
|
52 | - { |
|
51 | + public function safeDown() |
|
52 | + { |
|
53 | 53 | $this->dropTable('cms_static_content'); |
54 | - } |
|
54 | + } |
|
55 | 55 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | // recreate the table with the new structure |
12 | 12 | $this->execute("DROP TABLE IF EXISTS $cms_static"); |
13 | - $sql =<<<EOQ |
|
13 | + $sql = <<<EOQ |
|
14 | 14 | CREATE TABLE IF NOT EXISTS `cms_static_content` ( |
15 | 15 | `key` varchar(100) NOT NULL COMMENT 'a key to access the content' COLLATE utf8mb4_unicode_ci, |
16 | 16 | `page_id` INT UNSIGNED NULL COMMENT 'if provided, restrict content to the associated page', |
@@ -15,7 +15,7 @@ |
||
15 | 15 | $connection = \Yii::$app->getDb(); |
16 | 16 | |
17 | 17 | // create the various tables for dds |
18 | - $sql=<<<EOQ |
|
18 | + $sql = <<<EOQ |
|
19 | 19 | -- -------------------------------------------------------- |
20 | 20 | |
21 | 21 | -- |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function getThemeAlias() |
203 | 203 | { |
204 | - return '@root/themes/' . $this->getThemeName(); |
|
204 | + return '@root/themes/'.$this->getThemeName(); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @inheritdoc |
245 | 245 | * @unsupported - $filters is not currently supported |
246 | 246 | */ |
247 | - public function getDataMap($key, $query='', $filters=[], $fields=[], $start = 0, $limit = 100) |
|
247 | + public function getDataMap($key, $query = '', $filters = [], $fields = [], $start = 0, $limit = 100) |
|
248 | 248 | { |
249 | 249 | if ($key === 'pages') { |
250 | 250 | return $this->getPagesMap($query, $filters, $fields, $start, $limit); |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | */ |
298 | 298 | public function formatPageMapResults($pages, $fields) |
299 | 299 | { |
300 | - return collect($pages)->mapWithKeys(function ($item, $key) use($fields) { |
|
300 | + return collect($pages)->mapWithKeys(function($item, $key) use($fields) { |
|
301 | 301 | if (empty($fields)) |
302 | - return [$item['id'] => $item['nice_id'] . ': ' . $item['title']]; |
|
302 | + return [$item['id'] => $item['nice_id'].': '.$item['title']]; |
|
303 | 303 | return [$item['id'] => $item]; |
304 | 304 | })->all(); |
305 | 305 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @param array $fields |
328 | 328 | * @return array - @see $this->formatPageMapResults(); |
329 | 329 | */ |
330 | - public function getPagesMap($query=null, $filters=[], $fields=[], $start=0, $limit=100) |
|
330 | + public function getPagesMap($query = null, $filters = [], $fields = [], $start = 0, $limit = 100) |
|
331 | 331 | { |
332 | 332 | $pages = CmsPage::find() |
333 | 333 | ->select(array_merge(['id', 'nice_id', 'title'], $fields)) |
@@ -361,10 +361,10 @@ discard block |
||
361 | 361 | */ |
362 | 362 | private function checkThemeName($name) |
363 | 363 | { |
364 | - if ( preg_match('/[^A-Za-z0-9_-]/', $name, $matches) ) { |
|
364 | + if (preg_match('/[^A-Za-z0-9_-]/', $name, $matches)) { |
|
365 | 365 | throw new \InvalidArgumentException("Error trying to set the theme name to '$name'" |
366 | 366 | ."\n"."The theme name must consist of only 'a-z', '0-9', '_' and '-' characters." |
367 | - ."\n".'The following character is not allowed in theme names: ' . \yii\helpers\VarDumper::dumpAsString($matches[0]) ); |
|
367 | + ."\n".'The following character is not allowed in theme names: '.\yii\helpers\VarDumper::dumpAsString($matches[0])); |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 |
@@ -146,11 +146,13 @@ discard block |
||
146 | 146 | public function getThemeHierarchy() |
147 | 147 | { |
148 | 148 | // if we have a theme hierarchy use that |
149 | - if (count($this->_themeHierarchy)) |
|
150 | - return $this->_themeHierarchy; |
|
149 | + if (count($this->_themeHierarchy)) { |
|
150 | + return $this->_themeHierarchy; |
|
151 | + } |
|
151 | 152 | // otherwise drop back to the themeName |
152 | - if (!empty($this->_themeName)) |
|
153 | - return [$this->_themeName]; |
|
153 | + if (!empty($this->_themeName)) { |
|
154 | + return [$this->_themeName]; |
|
155 | + } |
|
154 | 156 | // otherwise return nothing |
155 | 157 | return []; |
156 | 158 | } |
@@ -261,8 +263,9 @@ discard block |
||
261 | 263 | */ |
262 | 264 | public function getMapResults($requestKey) |
263 | 265 | { |
264 | - if (!isset($this->_mapRequestKey[$requestKey])) |
|
265 | - throw new \InvalidArgumentException('The provided request key "'.$requestKey.'" does not exist'); |
|
266 | + if (!isset($this->_mapRequestKey[$requestKey])) { |
|
267 | + throw new \InvalidArgumentException('The provided request key "'.$requestKey.'" does not exist'); |
|
268 | + } |
|
266 | 269 | list($key, $ids, $fields) = $this->_mapRequestKey[$requestKey]; |
267 | 270 | if ($key === 'pages') { |
268 | 271 | $pages = CmsPage::find()->select(array_merge(['id', 'nice_id', 'title'], $fields)) |
@@ -298,8 +301,9 @@ discard block |
||
298 | 301 | public function formatPageMapResults($pages, $fields) |
299 | 302 | { |
300 | 303 | return collect($pages)->mapWithKeys(function ($item, $key) use($fields) { |
301 | - if (empty($fields)) |
|
302 | - return [$item['id'] => $item['nice_id'] . ': ' . $item['title']]; |
|
304 | + if (empty($fields)) { |
|
305 | + return [$item['id'] => $item['nice_id'] . ': ' . $item['title']]; |
|
306 | + } |
|
303 | 307 | return [$item['id'] => $item]; |
304 | 308 | })->all(); |
305 | 309 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @return array of |
34 | 34 | * ['class_type'] => [ 'class_type', 'module', 'label', 'description', ['deleted'] ] |
35 | 35 | */ |
36 | - public function listClasses(&$paginator=[], $filters=[], $orderBy=[], $includeDeleted=false); |
|
36 | + public function listClasses(&$paginator = [], $filters = [], $orderBy = [], $includeDeleted = false); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Create an IPhoebeClass interface for a new class reference. |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @throw \RuntimeException if the classRef already exists or something |
47 | 47 | * else went wrong during creation |
48 | 48 | */ |
49 | - public function addClass(&$classType, $module=''); |
|
49 | + public function addClass(&$classType, $module = ''); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Get hold of an IPhoebeClass interface for a particular class reference. |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @return null | \neon\phoebe\interfaces\IPhoebeClass |
60 | 60 | * returns null if the classType or version doesn't exist |
61 | 61 | */ |
62 | - public function getClass($classType, $version=null, $classOverrideCriteria=[]); |
|
62 | + public function getClass($classType, $version = null, $classOverrideCriteria = []); |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * Get hold of a set of IPhoebeClasses for a set of classType. The latest version |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * will return all rows that have been soft deleted. |
100 | 100 | * @return array an array of objects of this class |
101 | 101 | */ |
102 | - public function listObjects($classType, &$paginator=[], $filters=[], $orderBy=[], $additionalFields=[]); |
|
102 | + public function listObjects($classType, &$paginator = [], $filters = [], $orderBy = [], $additionalFields = []); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Create and save a new IPhoebeObject of a particular class type |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return \neon\phoebe\interfaces\IPhoebeObject |
112 | 112 | * @throw \RuntimeException if anything went wrong during the addition |
113 | 113 | */ |
114 | - public function addObject($classType, $classOverrideCriteria=[]); |
|
114 | + public function addObject($classType, $classOverrideCriteria = []); |
|
115 | 115 | |
116 | 116 | /** |
117 | 117 | * Get hold of a phoebe object interface for managing an instance |