From 76bcb09e96b0081b901ac4189e2dded69b17b31a Mon Sep 17 00:00:00 2001 From: Geo Dela Paz Date: Fri, 25 Oct 2019 10:34:29 +0800 Subject: [PATCH 1/8] Updated dotenv declaration to use the latest syntax --- common/env.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/env.php b/common/env.php index cc9753e54..86bcff9c7 100644 --- a/common/env.php +++ b/common/env.php @@ -7,7 +7,7 @@ /** * Load application environment from .env file */ -$dotenv = new \Dotenv\Dotenv(dirname(__DIR__)); +$dotenv = \Dotenv\Dotenv::create(dirname(__DIR__)); $dotenv->load(); /** From 509b40f7bf4e3d0e1dd71467741077b2a29574c1 Mon Sep 17 00:00:00 2001 From: Geo Dela Paz Date: Fri, 25 Oct 2019 10:34:48 +0800 Subject: [PATCH 2/8] Updated dotenv version to latest stable --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2ecbcfb17..37a16e772 100755 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "trntv/cheatsheet": "^0.1@dev", "trntv/yii2-command-bus": "^3.0", "intervention/image": "^2.1", - "vlucas/phpdotenv": "^2.0", + "vlucas/phpdotenv": "@stable", "npm-asset/admin-lte": "^2.0", "npm-asset/font-awesome": "^4.0", "npm-asset/html5shiv": "^3.0", From 9ba121457d839659d39314112c6fc8216fd2a53a Mon Sep 17 00:00:00 2001 From: nikosid Date: Sat, 2 Nov 2019 12:33:39 +0100 Subject: [PATCH 3/8] Correcting api routes and their tests --- api/config/_urlManager.php | 2 +- tests/api/functional/ArticleCest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/config/_urlManager.php b/api/config/_urlManager.php index 59915969f..daa34d367 100755 --- a/api/config/_urlManager.php +++ b/api/config/_urlManager.php @@ -5,6 +5,6 @@ 'showScriptName' => false, 'rules' => [ // Api - ['class' => 'yii\rest\UrlRule', 'controller' => 'api/v1/article', 'only' => ['index', 'view', 'options']], + ['class' => 'yii\rest\UrlRule', 'controller' => 'v1/article', 'only' => ['index', 'view', 'options']], ] ]; diff --git a/tests/api/functional/ArticleCest.php b/tests/api/functional/ArticleCest.php index ac6dd1713..7fdcc7c86 100644 --- a/tests/api/functional/ArticleCest.php +++ b/tests/api/functional/ArticleCest.php @@ -10,13 +10,13 @@ class ArticleCest extends ApiCest // tests public function testArticlesList(FunctionalTester $I) { - $I->amOnPage('/v1/article'); + $I->amOnPage('/v1/articles'); $I->see('Lorem ipsum'); } public function testArticleView(FunctionalTester $I) { - $I->amOnPage(['/v1/article', 'slug' => 'test-article-1']); + $I->amOnPage(['/v1/articles', 'slug' => 'test-article-1']); $I->see('Lorem ipsum'); } } From 3b96d7662da7d8e0917126f0125f20e050654cb0 Mon Sep 17 00:00:00 2001 From: nikosid Date: Sun, 16 Feb 2020 14:31:15 +0100 Subject: [PATCH 4/8] rbac_auth_rule data fix --- .../fixtures/data/rbac_auth_assignment.php | 18 ++--- tests/common/fixtures/data/rbac_auth_item.php | 81 +++++++++---------- .../fixtures/data/rbac_auth_item_child.php | 26 +++--- tests/common/fixtures/data/rbac_auth_rule.php | 16 ++-- 4 files changed, 58 insertions(+), 83 deletions(-) diff --git a/tests/common/fixtures/data/rbac_auth_assignment.php b/tests/common/fixtures/data/rbac_auth_assignment.php index c14b7520e..65a0a67bd 100644 --- a/tests/common/fixtures/data/rbac_auth_assignment.php +++ b/tests/common/fixtures/data/rbac_auth_assignment.php @@ -1,25 +1,19 @@ "administrator", - 'user_id' => "1", + 'item_name' => 'administrator', + 'user_id' => '1', 'created_at' => '1440552894', ], [ - 'item_name' => "manager", - 'user_id' => "2", + 'item_name' => 'manager', + 'user_id' => '2', 'created_at' => '1440552894', ], [ - 'item_name' => "user", - 'user_id' => "3", + 'item_name' => 'user', + 'user_id' => '3', 'created_at' => '1440552894', ], ]; diff --git a/tests/common/fixtures/data/rbac_auth_item.php b/tests/common/fixtures/data/rbac_auth_item.php index 3d5bb1d36..e56a5384a 100644 --- a/tests/common/fixtures/data/rbac_auth_item.php +++ b/tests/common/fixtures/data/rbac_auth_item.php @@ -1,56 +1,49 @@ "administrator", - "type" => "1", - "description" => "", - "rule_name" => null, - "data" => "", - "created_at" => "1508507788", - "updated_at" => "1508507788" + 'name' => 'administrator', + 'type' => '1', + 'description' => '', + 'rule_name' => null, + 'data' => '', + 'created_at' => '1508507788', + 'updated_at' => '1508507788', ], [ - "name" => "editOwnModel", - "type" => "2", - "description" => "", - "rule_name" => "ownModelRule", - "data" => "", - "created_at" => "1508507788", - "updated_at" => "1508507788" + 'name' => 'editOwnModel', + 'type' => '2', + 'description' => '', + 'rule_name' => 'ownModelRule', + 'data' => '', + 'created_at' => '1508507788', + 'updated_at' => '1508507788', ], [ - "name" => "loginToBackend", - "type" => "2", - "description" => "", - "rule_name" => null, - "data" => "", - "created_at" => "1508507788", - "updated_at" => "1508507788" + 'name' => 'loginToBackend', + 'type' => '2', + 'description' => '', + 'rule_name' => null, + 'data' => '', + 'created_at' => '1508507788', + 'updated_at' => '1508507788', ], [ - "name" => "manager", - "type" => "1", - "description" => "", - "rule_name" => null, - "data" => "", - "created_at" => "1508507787", - "updated_at" => "1508507787" + 'name' => 'manager', + 'type' => '1', + 'description' => '', + 'rule_name' => null, + 'data' => '', + 'created_at' => '1508507787', + 'updated_at' => '1508507787', ], [ - "name" => "user", - "type" => "1", - "description" => "", - "rule_name" => null, - "data" => "", - "created_at" => "1508507787", - "updated_at" => "1508507787" - ] -]; \ No newline at end of file + 'name' => 'user', + 'type' => '1', + 'description' => '', + 'rule_name' => null, + 'data' => '', + 'created_at' => '1508507787', + 'updated_at' => '1508507787', + ], +]; diff --git a/tests/common/fixtures/data/rbac_auth_item_child.php b/tests/common/fixtures/data/rbac_auth_item_child.php index 0b0693ebf..781041b11 100644 --- a/tests/common/fixtures/data/rbac_auth_item_child.php +++ b/tests/common/fixtures/data/rbac_auth_item_child.php @@ -1,26 +1,20 @@ "user", - "child" => "editOwnModel" + 'parent' => 'user', + 'child' => 'editOwnModel', ], [ - "parent" => "manager", - "child" => "loginToBackend" + 'parent' => 'manager', + 'child' => 'loginToBackend', ], [ - "parent" => "administrator", - "child" => "manager" + 'parent' => 'administrator', + 'child' => 'manager', ], [ - "parent" => "manager", - "child" => "user" - ] -]; \ No newline at end of file + 'parent' => 'manager', + 'child' => 'user', + ], +]; diff --git a/tests/common/fixtures/data/rbac_auth_rule.php b/tests/common/fixtures/data/rbac_auth_rule.php index 31c9f266d..5616fcf88 100644 --- a/tests/common/fixtures/data/rbac_auth_rule.php +++ b/tests/common/fixtures/data/rbac_auth_rule.php @@ -1,16 +1,10 @@ "ownModelRule", - "data" => "TzoyOToiY29tbW9uXHJiYWNccnVsZVxPd25Nb2RlbFJ1bGUiOjM6e3M6NDoibmFtZSI7czoxMjoib3duTW9kZWxSdWxlIjtzOjk6ImNyZWF0ZWRBdCI7aToxNTA4NTA3Nzg4O3M6OToidXBkYXRlZEF0IjtpOjE1MDg1MDc3ODg7fQ==", - "created_at" => "1508507788", - "updated_at" => "1508507788" + 'name' => 'ownModelRule', + 'data' => 'O:29:"common\rbac\rule\OwnModelRule":3:{s:4:"name";s:12:"ownModelRule";s:9:"createdAt";i:1508507788;s:9:"updatedAt";i:1508507788;}', + 'created_at' => '1508507788', + 'updated_at' => '1508507788' ] -]; \ No newline at end of file +]; From d72fc6a65b35c8e6ab607f2f92865b1cfba025cc Mon Sep 17 00:00:00 2001 From: nikosid Date: Tue, 10 Mar 2020 09:51:20 +0100 Subject: [PATCH 5/8] Code formatting --- common/config/base.php | 2 +- common/config/bootstrap.php | 18 +++++++++--------- common/config/messages/db.php | 2 +- common/config/messages/php.php | 2 +- common/config/messages/po.php | 2 +- frontend/controllers/ArticleController.php | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/common/config/base.php b/common/config/base.php index cc203223b..c2ff14d58 100755 --- a/common/config/base.php +++ b/common/config/base.php @@ -100,7 +100,7 @@ 'on missingTranslation' => [backend\modules\translation\Module::class, 'missingTranslation'] ], /* Uncomment this code to use DbMessageSource - '*'=> [ + '*'=> [ 'class' => 'yii\i18n\DbMessageSource', 'sourceMessageTable'=>'{{%i18n_source_message}}', 'messageTable'=>'{{%i18n_message}}', diff --git a/common/config/bootstrap.php b/common/config/bootstrap.php index 0598f7883..38c9a5b34 100644 --- a/common/config/bootstrap.php +++ b/common/config/bootstrap.php @@ -2,19 +2,19 @@ /** * Require core files */ -require_once(__DIR__ . '/../helpers.php'); +require_once __DIR__ . '/../helpers.php'; /** * Setting path aliases */ -Yii::setAlias('@base', realpath(__DIR__ . '/../../')); -Yii::setAlias('@common', realpath(__DIR__ . '/../../common')); -Yii::setAlias('@api', realpath(__DIR__ . '/../../api')); -Yii::setAlias('@frontend', realpath(__DIR__ . '/../../frontend')); -Yii::setAlias('@backend', realpath(__DIR__ . '/../../backend')); -Yii::setAlias('@console', realpath(__DIR__ . '/../../console')); -Yii::setAlias('@storage', realpath(__DIR__ . '/../../storage')); -Yii::setAlias('@tests', realpath(__DIR__ . '/../../tests')); +Yii::setAlias('@base', dirname(__DIR__, 2) . '/'); +Yii::setAlias('@common', dirname(__DIR__, 2) . '/common'); +Yii::setAlias('@api', dirname(__DIR__, 2) . '/api'); +Yii::setAlias('@frontend', dirname(__DIR__, 2) . '/frontend'); +Yii::setAlias('@backend', dirname(__DIR__, 2) . '/backend'); +Yii::setAlias('@console', dirname(__DIR__, 2) . '/console'); +Yii::setAlias('@storage', dirname(__DIR__, 2) . '/storage'); +Yii::setAlias('@tests', dirname(__DIR__, 2) . '/tests'); /** * Setting url aliases diff --git a/common/config/messages/db.php b/common/config/messages/db.php index aefb28826..e9ae5151c 100755 --- a/common/config/messages/db.php +++ b/common/config/messages/db.php @@ -1,7 +1,7 @@ 'db', diff --git a/common/config/messages/php.php b/common/config/messages/php.php index 991f66f52..7f4113afd 100755 --- a/common/config/messages/php.php +++ b/common/config/messages/php.php @@ -1,7 +1,7 @@ 'php', diff --git a/common/config/messages/po.php b/common/config/messages/po.php index 2f46c9e2c..adbb8a6d5 100755 --- a/common/config/messages/po.php +++ b/common/config/messages/po.php @@ -1,7 +1,7 @@ 'po', diff --git a/frontend/controllers/ArticleController.php b/frontend/controllers/ArticleController.php index e5c4c6217..b15ea1c3a 100755 --- a/frontend/controllers/ArticleController.php +++ b/frontend/controllers/ArticleController.php @@ -45,7 +45,7 @@ public function actionView($slug) /** * @param $id - * @return $this + * @return string * @throws NotFoundHttpException * @throws \yii\web\HttpException */ From e354c565365270602ff8be91a652c2a7e3c2f770 Mon Sep 17 00:00:00 2001 From: nikosid Date: Tue, 10 Mar 2020 09:52:03 +0100 Subject: [PATCH 6/8] =?UTF-8?q?=D0=86=D0=BC'=D1=8F=20instead=20of=20=D0=98?= =?UTF-8?q?=D0=BC'=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/messages/uk/common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/messages/uk/common.php b/common/messages/uk/common.php index 563f5ec71..5be8399de 100644 --- a/common/messages/uk/common.php +++ b/common/messages/uk/common.php @@ -53,7 +53,7 @@ 'Lastname' => 'Прізвище', 'Locale' => 'Локаль', 'Middlename' => 'По батькові', - 'Name' => 'Им\'я', + 'Name' => 'Ім\'я', 'Order' => 'Порядок', 'Page View' => 'Шаблон сторінки', 'Parent Category' => 'Батьківська категорія', @@ -73,6 +73,6 @@ 'Upload Ip' => 'IP', 'Url' => 'Url', 'User ID' => 'ID Користувача', - 'Username' => 'Им’я користувача', + 'Username' => 'Ім’я користувача', 'Value' => 'Значення', ]; From d5341a02da95b97eaa41ae3ee90ce841bbc47515 Mon Sep 17 00:00:00 2001 From: nikosid Date: Tue, 10 Mar 2020 09:55:31 +0100 Subject: [PATCH 7/8] Code formatting --- common/config/base.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/common/config/base.php b/common/config/base.php index f80e5cc96..11af182fc 100755 --- a/common/config/base.php +++ b/common/config/base.php @@ -16,12 +16,12 @@ 'itemTable' => '{{%rbac_auth_item}}', 'itemChildTable' => '{{%rbac_auth_item_child}}', 'assignmentTable' => '{{%rbac_auth_assignment}}', - 'ruleTable' => '{{%rbac_auth_rule}}' + 'ruleTable' => '{{%rbac_auth_rule}}', ], 'cache' => [ 'class' => yii\caching\FileCache::class, - 'cachePath' => '@common/runtime/cache' + 'cachePath' => '@common/runtime/cache', ], 'commandBus' => [ @@ -31,12 +31,12 @@ 'class' => trntv\bus\middlewares\BackgroundCommandMiddleware::class, 'backgroundHandlerPath' => '@console/yii', 'backgroundHandlerRoute' => 'command-bus/handle', - ] - ] + ], + ], ], 'formatter' => [ - 'class' => yii\i18n\Formatter::class + 'class' => yii\i18n\Formatter::class, ], 'glide' => [ @@ -45,15 +45,15 @@ 'cachePath' => '@storage/cache', 'urlManager' => 'urlManagerStorage', 'maxImageSize' => env('GLIDE_MAX_IMAGE_SIZE'), - 'signKey' => env('GLIDE_SIGN_KEY') + 'signKey' => env('GLIDE_SIGN_KEY'), ], 'mailer' => [ 'class' => yii\swiftmailer\Mailer::class, 'messageConfig' => [ 'charset' => 'UTF-8', - 'from' => env('ADMIN_EMAIL') - ] + 'from' => env('ADMIN_EMAIL'), + ], ], 'db' => [ @@ -78,8 +78,8 @@ return sprintf('[%s][%s]', Yii::$app->id, $url); }, 'logVars' => [], - 'logTable' => '{{%system_log}}' - ] + 'logTable' => '{{%system_log}}', + ], ], ], @@ -93,7 +93,7 @@ 'backend' => 'backend.php', 'frontend' => 'frontend.php', ], - 'on missingTranslation' => [backend\modules\translation\Module::class, 'missingTranslation'] + 'on missingTranslation' => [backend\modules\translation\Module::class, 'missingTranslation'], ], /* Uncomment this code to use DbMessageSource '*'=> [ @@ -113,16 +113,16 @@ 'baseUrl' => '@storageUrl/source', 'filesystem' => [ 'class' => common\components\filesystem\LocalFlysystemBuilder::class, - 'path' => '@storage/web/source' + 'path' => '@storage/web/source', ], 'as log' => [ 'class' => common\behaviors\FileStorageLogBehavior::class, - 'component' => 'fileStorage' - ] + 'component' => 'fileStorage', + ], ], 'keyStorage' => [ - 'class' => common\components\keyStorage\KeyStorage::class + 'class' => common\components\keyStorage\KeyStorage::class, ], 'urlManagerBackend' => \yii\helpers\ArrayHelper::merge( @@ -173,18 +173,18 @@ 'class' => yii\log\EmailTarget::class, 'except' => ['yii\web\HttpException:*'], 'levels' => ['error', 'warning'], - 'message' => ['from' => env('ROBOT_EMAIL'), 'to' => env('ADMIN_EMAIL')] + 'message' => ['from' => env('ROBOT_EMAIL'), 'to' => env('ADMIN_EMAIL')], ]; } if (YII_ENV_DEV) { $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ - 'class' => yii\gii\Module::class + 'class' => yii\gii\Module::class, ]; $config['components']['cache'] = [ - 'class' => yii\caching\DummyCache::class + 'class' => yii\caching\DummyCache::class, ]; $config['components']['mailer']['transport'] = [ 'class' => 'Swift_SmtpTransport', From 6274504ca1180bd414c4339b5242f8e6f653f571 Mon Sep 17 00:00:00 2001 From: nikosid Date: Tue, 10 Mar 2020 09:57:24 +0100 Subject: [PATCH 8/8] Code formatting --- common/config/base.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/config/base.php b/common/config/base.php index 11af182fc..1d3d625b0 100755 --- a/common/config/base.php +++ b/common/config/base.php @@ -97,12 +97,12 @@ ], /* Uncomment this code to use DbMessageSource '*'=> [ - 'class' => 'yii\i18n\DbMessageSource', + 'class' => yii\i18n\DbMessageSource::class, 'sourceMessageTable'=>'{{%i18n_source_message}}', 'messageTable'=>'{{%i18n_message}}', 'enableCaching' => YII_ENV_DEV, 'cachingDuration' => 3600, - 'on missingTranslation' => ['\backend\modules\translation\Module', 'missingTranslation'] + 'on missingTranslation' => [backend\modules\translation\Module::class, 'missingTranslation'] ], */ ],