controller->module; $version = $module->version; $welcome = '╔════════════════════════════════════════════════╗'. "\n" . '║ ║'. "\n" . '║ YANDEX.TURBO MODULE, v.'.$version.' ║'. "\n" . '║ by Alexsander Vyshnyvetskyy ║'. "\n" . '║ (c) 2019-2020 W.D.M.Group, Ukraine ║'. "\n" . '║ ║'. "\n" . '╚════════════════════════════════════════════════╝'; echo $name = $this->ansiFormat($welcome . "\n\n", Console::FG_GREEN); echo "Select the operation you want to perform:\n"; echo " 1) Apply all module migrations\n"; echo " 2) Revert all module migrations\n"; echo " 3) Flush Yandex turbo-pages cache\n"; echo "Your choice: "; if(!is_null($this->choice)) $selected = $this->choice; else $selected = trim(fgets(STDIN)); if ($selected == "1") { Yii::$app->runAction('migrate/up', ['migrationPath' => '@vendor/wdmg/yii2-turbo/migrations', 'interactive' => true]); } else if($selected == "2") { Yii::$app->runAction('migrate/down', ['migrationPath' => '@vendor/wdmg/yii2-turbo/migrations', 'interactive' => true]); } else if($selected == "3") { if ($cache = Yii::$app->getCache()) { if ($cache->delete(md5('yandex-turbo'))) { echo $this->ansiFormat("OK! Yandex turbo-pages cache successfully cleaned.\n\n", Console::FG_GREEN); } else { echo $this->ansiFormat("An error occurred while cleaning a Yandex turbo-pages cache.\n\n", Console::FG_RED); } } else { echo $this->ansiFormat("Error! Cache component not configured in application.\n\n", Console::FG_RED); } } else { echo $this->ansiFormat("Error! Your selection has not been recognized.\n\n", Console::FG_RED); return ExitCode::UNSPECIFIED_ERROR; } echo "\n"; return ExitCode::OK; } }