当前位置: 首页>>代码示例>>PHP>>正文


PHP helpers\Console类代码示例

本文整理汇总了PHP中yii\helpers\Console的典型用法代码示例。如果您正苦于以下问题:PHP Console类的具体用法?PHP Console怎么用?PHP Console使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Console类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionInit

 public function actionInit()
 {
     $auth = Yii::$app->authManager;
     $auth->removeAll();
     $user = $auth->createRole(User::ROLE_USER);
     $auth->add($user);
     // own model rule
     $ownModelRule = new OwnModelRule();
     $auth->add($ownModelRule);
     $manager = $auth->createRole(User::ROLE_MANAGER);
     $auth->add($manager);
     $auth->addChild($manager, $user);
     $loginToBackend = $auth->createPermission('loginToBackend');
     $auth->add($loginToBackend);
     $auth->addChild($manager, $loginToBackend);
     $publisher = $auth->createRole(User::ROLE_PUBLISHER);
     $auth->add($publisher);
     $auth->addChild($publisher, $loginToBackend);
     $advertiser = $auth->createRole(User::ROLE_ADVERTISER);
     $auth->add($advertiser);
     $auth->addChild($advertiser, $loginToBackend);
     $admin = $auth->createRole(User::ROLE_ADMINISTRATOR);
     $auth->add($admin);
     $auth->addChild($admin, $manager);
     $auth->assign($admin, 1);
     $auth->assign($manager, 2);
     $auth->assign($user, 3);
     $auth->assign($publisher, 4);
     $auth->assign($advertiser, 5);
     Console::output('Success! RBAC roles has been added.');
 }
开发者ID:Sywooch,项目名称:AVSProduct,代码行数:31,代码来源:RbacController.php

示例2: actionInit

 public function actionInit()
 {
     $auth = Yii::$app->authManager;
     $auth->removeAll();
     $user = $auth->createRole(User::ROLE_USER);
     $auth->add($user);
     // own model rule
     $ownModelRule = new OwnModelRule();
     $auth->add($ownModelRule);
     $submissionRule = new SubmissionRule();
     $auth->add($submissionRule);
     $updateOwnResearch = $auth->createPermission('updateOwnResearch');
     $updateOwnResearch->description = 'update research by status';
     $updateOwnResearch->ruleName = $submissionRule->name;
     $auth->add($updateOwnResearch);
     $auth->addChild($user, $updateOwnResearch);
     $manager = $auth->createRole(User::ROLE_MANAGER);
     $auth->add($manager);
     $auth->addChild($manager, $user);
     $loginToBackend = $auth->createPermission('loginToBackend');
     $auth->add($loginToBackend);
     $auth->addChild($manager, $loginToBackend);
     $admin = $auth->createRole(User::ROLE_ADMINISTRATOR);
     $auth->add($admin);
     $auth->addChild($admin, $manager);
     $auth->assign($admin, 1);
     $auth->assign($manager, 2);
     $auth->assign($user, 3);
     Console::output('Success! RBAC roles has been added.');
 }
开发者ID:khonkaen-hospital,项目名称:KIRB,代码行数:30,代码来源:RbacController.php

示例3: stderr

 protected function stderr($string)
 {
     if (Console::streamSupportsAnsiColors(\STDOUT)) {
         $string = Console::ansiFormat("    Error: " . $string, [Console::FG_RED]);
     }
     return fwrite(\STDERR, $string);
 }
开发者ID:inblank,项目名称:yii2-activeuser,代码行数:7,代码来源:Migration.php

示例4: showErrors

 /**
  * Show errors
  * @param array $errors array of errors string
  * @throws yii\base\ExitException
  */
 protected function showErrors($errors)
 {
     foreach ((array) $errors as $err) {
         Console::error(Console::ansiFormat(Yii::t('activeuser_backend', "Error") . ": ", [Console::FG_RED]) . $err[0]);
     }
     yii::$app->end();
 }
开发者ID:inblank,项目名称:yii2-activeuser,代码行数:12,代码来源:ConsoleController.php

示例5: initRbac

 /**
  * 初始默认角色数据
  */
 public function initRbac()
 {
     Console::output('初始化RBAC数据 ....');
     $auth = Yii::$app->authManager;
     /* ================= 权限 ================= */
     $visitAdmin = $auth->createPermission('visitAdmin');
     $visitAdmin->description = '访问后台管理界面权限';
     $auth->add($visitAdmin);
     /* ================= 身份 ================= */
     $guest = $auth->createRole('guest');
     // 匿名用户
     $guest->description = '匿名用户';
     $auth->add($guest);
     $user = $auth->createRole('user');
     //普通用户
     $user->description = '普通用户';
     $auth->add($user, $guest);
     //普通用户 > 匿名用户
     $admin = $auth->createRole('admin');
     // 管理员
     $admin->description = '管理员';
     $auth->add($admin);
     $auth->addChild($admin, $user);
     // 管理员 > 普通用户
     $auth->addChild($admin, $visitAdmin);
     // 管理员可以访问后台
     $founder = $auth->createRole('founder');
     // 创始人
     $founder->description = '创始人';
     $auth->add($founder);
     $auth->addChild($founder, $admin);
     // 创始人 > 管理员
     Console::output('初始化RBAC数据完成 ....');
 }
开发者ID:rocketyang,项目名称:huajuan,代码行数:37,代码来源:m150106_020316_initRbacTable.php

示例6: actionInit

 public function actionInit()
 {
     $auth = Yii::$app->authManager;
     $user = $auth->createRole(User::ROLE_USER);
     $auth->add($user);
     Console::output('Success! RBAC roles has been added.');
 }
开发者ID:vitalik74,项目名称:gosman-test-app,代码行数:7,代码来源:RbacController.php

示例7: saveMessagesToPHP

 /**
  * @inheritdoc
  */
 protected function saveMessagesToPHP($messages, $dirName, $overwrite, $removeUnused, $sort, $markUnused)
 {
     $dirNameBase = $dirName;
     foreach ($messages as $category => $msgs) {
         /**
          * Fix Directory
          */
         $module = $this->getModuleByCategory($category);
         if ($module !== null) {
             // Use Module Directory
             $dirName = str_replace(Yii::getAlias("@humhub/messages"), $module->getBasePath() . '/messages', $dirNameBase);
             preg_match('/.*?Module\\.(.*)/', $category, $result);
             $category = $result[1];
         } else {
             // Use Standard HumHub Directory
             $dirName = $dirNameBase;
         }
         $file = str_replace("\\", '/', "{$dirName}/{$category}.php");
         $path = dirname($file);
         FileHelper::createDirectory($path);
         $msgs = array_values(array_unique($msgs));
         $coloredFileName = Console::ansiFormat($file, [Console::FG_CYAN]);
         $this->stdout("Saving messages to {$coloredFileName}...\n");
         $this->saveMessagesCategoryToPHP($msgs, $file, $overwrite, $removeUnused, $sort, $category, $markUnused);
     }
 }
开发者ID:freddykr,项目名称:humhub,代码行数:29,代码来源:MessageController.php

示例8: actionRefreshOnline

 /**
  * Снимаем онлайн у тех, у кого за последнее время активность == 0
  */
 public function actionRefreshOnline()
 {
     $oldTime = time() - \Yii::$app->params['onlineLength'];
     $userUpdated = User::updateAll(['<=', 'updated', $oldTime]);
     $this->stdout(Console::wrapText("- {$userUpdated} отправлено в оффлайн", 10), Console::BOLD);
     $this->stdout("\n");
 }
开发者ID:KPEMATOP,项目名称:findspree_old,代码行数:10,代码来源:UserController.php

示例9: processCron

 /**
  * Processes update e-mails for all users
  */
 public static function processCron($controller)
 {
     // Detect the mailing interval we're in
     $interval = 0;
     if (Yii::$app->controller->action->id == 'hourly') {
         $interval = self::INTERVAL_HOURY;
     } elseif (Yii::$app->controller->action->id == 'daily') {
         $interval = self::INTERVAL_DAILY;
     } else {
         throw new \yii\console\Exception('Invalid mail update interval!');
     }
     // Get users
     $users = User::find()->distinct()->joinWith(['httpSessions', 'profile'])->where(['user.status' => User::STATUS_ENABLED]);
     $totalUsers = $users->count();
     $processed = 0;
     Console::startProgress($processed, $totalUsers, 'Sending update e-mails to users... ', false);
     $mailsSent = 0;
     foreach ($users->each() as $user) {
         $mailSender = new self();
         $mailSender->user = $user;
         $mailSender->interval = $interval;
         if ($mailSender->send()) {
             $mailsSent++;
         }
         Console::updateProgress(++$processed, $totalUsers);
     }
     Console::endProgress(true);
     $controller->stdout('done - ' . $mailsSent . ' email(s) sent.' . PHP_EOL, Console::FG_GREEN);
     // Switch back to system language
     self::switchLanguage();
 }
开发者ID:kreativmind,项目名称:humhub,代码行数:34,代码来源:MailUpdateSender.php

示例10: actionCreate

 /**
  * Create a new frontend/admin module.
  *
  * @return number
  */
 public function actionCreate()
 {
     Console::clearScreenBeforeCursor();
     $moduleName = $this->prompt("Enter the name of the module you like to generate:");
     $newName = preg_replace("/[^a-z]/", "", strtolower($moduleName));
     if ($newName !== $moduleName) {
         if (!$this->confirm("We have changed the name to '{$newName}'. Do you want to proceed with this name?")) {
             return $this->outputError('Abort by user.');
         } else {
             $moduleName = $newName;
         }
     }
     $appModulesFolder = Yii::$app->basePath . DIRECTORY_SEPARATOR . 'modules';
     $moduleFolder = $appModulesFolder . DIRECTORY_SEPARATOR . $moduleName;
     if (file_exists($moduleFolder)) {
         return $this->outputError("The folder " . $moduleFolder . " exists already.");
     }
     $folders = ['basePath' => $moduleFolder, 'adminPath' => $moduleFolder . DIRECTORY_SEPARATOR . 'admin', 'adminPath' => $moduleFolder . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'aws', 'frontendPath' => $moduleFolder . DIRECTORY_SEPARATOR . 'frontend', 'blocksPath' => $moduleFolder . DIRECTORY_SEPARATOR . 'frontend' . DIRECTORY_SEPARATOR . 'blocks', 'blocksPath' => $moduleFolder . DIRECTORY_SEPARATOR . 'frontend' . DIRECTORY_SEPARATOR . 'controllers', 'blocksPath' => $moduleFolder . DIRECTORY_SEPARATOR . 'frontend' . DIRECTORY_SEPARATOR . 'views', 'modelsPath' => $moduleFolder . DIRECTORY_SEPARATOR . 'models'];
     $ns = 'app\\modules\\' . $moduleName;
     foreach ($folders as $folder) {
         FileHelper::createDirectory($folder);
     }
     $contents = [$moduleFolder . DIRECTORY_SEPARATOR . 'README.md' => $this->renderReadme($folders, $moduleName, $ns), $moduleFolder . DIRECTORY_SEPARATOR . 'admin/Module.php' => $this->renderAdmin($folders, $moduleName, $ns), $moduleFolder . DIRECTORY_SEPARATOR . 'frontend/Module.php' => $this->renderFrontend($folders, $moduleName, $ns)];
     foreach ($contents as $fileName => $content) {
         FileHelper::writeFile($fileName, $content);
     }
     return $this->outputSuccess("Module files has been created successfull. Check the README file to understand how to added the module to your config.");
 }
开发者ID:luyadev,项目名称:luya-core,代码行数:33,代码来源:ModuleController.php

示例11: actionIndex

 public function actionIndex()
 {
     $this->stdout('Description goes here.' . PHP_EOL);
     $helpCommand = Console::ansiFormat("yii help dota2api/economy", [Console::FG_CYAN]);
     $this->stdout("Use {$helpCommand} to get usage info." . PHP_EOL);
     return self::EXIT_CODE_NORMAL;
 }
开发者ID:aldegtyarev,项目名称:fantasy,代码行数:7,代码来源:EconomyController.php

示例12: actionInit

 public function actionInit()
 {
     $auth = Yii::$app->authManager;
     $auth->removeAll();
     Console::output('Removing All! RBAC.....');
     $manageUser = $auth->createRole('ManageUser');
     $manageUser->description = 'สำหรับจัดการข้อมูลผู้ใช้งาน';
     $auth->add($manageUser);
     $author = $auth->createRole('Author');
     $author->description = 'สำหรับการเขียนบทความ';
     $auth->add($author);
     $management = $auth->createRole('Management');
     $management->description = 'สำหรับจัดการข้อมูลผู้ใช้งานและบทความ';
     $auth->add($management);
     $admin = $auth->createRole('Admin');
     $admin->description = 'สำหรับการดูแลระบบ';
     $auth->add($admin);
     $auth->addChild($management, $manageUser);
     $auth->addChild($management, $author);
     $auth->addChild($admin, $management);
     $auth->assign($admin, 1);
     $auth->assign($management, 2);
     $auth->assign($author, 3);
     Console::output('Success! RBAC roles has been added.');
 }
开发者ID:veegithub,项目名称:yii2basic,代码行数:25,代码来源:RbacController.php

示例13: startHead

 public function startHead($controller, $headType, $headId, $restarting)
 {
     if (!$restarting) {
         // Console::output(Console::ansiFormat('Starting ' . $headId, [Console::FG_CYAN]));
     } else {
         // Console::output(Console::ansiFormat('Restarting ' . $headId, [Console::FG_CYAN]));
     }
     $_this = $this;
     $process = new \React\ChildProcess\Process($this->getSubCommand($controller, [$headType, $headId]));
     $process->on('exit', function ($exitCode, $termSignal) use(&$_this, &$controller, $headType, $headId) {
         if ($exitCode !== 0) {
             Console::stderr(Console::ansiFormat("Broadcast head {$headType}:{$headId} exited with error code {$exitCode}", [Console::FG_RED]));
             sleep(10);
         }
         if (static::isPaused()) {
             Yii::$app->end(0);
         }
         $_this->_heads[$headId] = $_this->startHead($controller, $headType, $headId, true);
     });
     $this->loop->addTimer(0.0001, function ($timer) use($process, &$_this) {
         $process->start($timer->getLoop());
         $process->stdout->on('data', function ($output) use($_this) {
             $stdout = fopen('php://stdout', 'w+');
             fwrite($stdout, $output);
         });
         $process->stderr->on('data', function ($output) use($_this) {
             $stderr = fopen('php://stderr', 'w+');
             fwrite($stderr, $output);
         });
     });
     sleep(5);
     return $process;
 }
开发者ID:psesd,项目名称:sensor-hub,代码行数:33,代码来源:Daemon.php

示例14: render

 /**
  * @inheritDoc
  */
 public function render($files, $targetDir)
 {
     //        $types = array_merge($this->apiContext->classes, $this->apiContext->interfaces, $this->apiContext->traits);
     //
     //        $extTypes = [];
     //        foreach ($this->extensions as $k => $ext) {
     //            $extType = $this->filterTypes($types, $ext);
     //            if (empty($extType)) {
     //                unset($this->extensions[$k]);
     //                continue;
     //            }
     //            $extTypes[$ext] = $extType;
     //        }
     $fileCount = count($files) + 1;
     if ($this->controller !== null) {
         Console::startProgress(0, $fileCount, 'Rendering markdown files: ', false);
     }
     $done = 0;
     $fileData = [];
     $chapters = $this->loadGuideStructure($files);
     foreach ($files as $file) {
         $fileData[basename($file)] = file_get_contents($file);
         //            if (preg_match("/^(.*)\n=+/", $fileData[$file], $matches)) {
         //                $headlines[$file] = $matches[1];
         //            } else {
         //                $headlines[$file] = basename($file);
         //            }
     }
     $md = new ApiMarkdownLaTeX();
     $output = '';
     foreach ($chapters as $chapter) {
         if (isset($chapter['headline'])) {
             $output .= '\\chapter{' . $chapter['headline'] . "}\n";
         }
         foreach ($chapter['content'] as $content) {
             if (isset($fileData[$content['file']])) {
                 $md->labelPrefix = $content['file'] . '#';
                 $output .= '\\label{' . $content['file'] . '}';
                 $output .= $md->parse($fileData[$content['file']]) . "\n\n";
             } else {
                 $output .= '\\newpage';
                 $output .= '\\label{' . $content['file'] . '}';
                 $output .= '\\textbf{Error: not existing file: ' . $content['file'] . '}\\newpage' . "\n";
             }
             if ($this->controller !== null) {
                 Console::updateProgress(++$done, $fileCount);
             }
         }
     }
     file_put_contents($targetDir . '/guide.tex', $output);
     copy(__DIR__ . '/main.tex', $targetDir . '/main.tex');
     copy(__DIR__ . '/title.tex', $targetDir . '/title.tex');
     copy(__DIR__ . '/Makefile', $targetDir . '/Makefile');
     if ($this->controller !== null) {
         Console::updateProgress(++$done, $fileCount);
         Console::endProgress(true);
         $this->controller->stdout('done.' . PHP_EOL, Console::FG_GREEN);
     }
     echo "\nnow run `make` in {$targetDir} (you need pdflatex to compile pdf file)\n\n";
 }
开发者ID:yiisoft,项目名称:yii2-apidoc,代码行数:63,代码来源:GuideRenderer.php

示例15: actionInit

 public function actionInit()
 {
     $auth = Yii::$app->authManager;
     $auth->removeAll();
     $user = $auth->createRole(User::ROLE_USER);
     $user->description = 'User';
     $auth->add($user);
     // own model rule
     $ownModelRule = new OwnModelRule();
     $auth->add($ownModelRule);
     $manager = $auth->createRole(User::ROLE_MANAGER);
     $manager->description = 'Manager';
     $auth->add($manager);
     $auth->addChild($manager, $user);
     $loginToBackend = $auth->createPermission('loginToBackend');
     $loginToBackend->description = 'Login to backend';
     $auth->add($loginToBackend);
     $auth->addChild($manager, $loginToBackend);
     $admin = $auth->createRole(User::ROLE_ADMINISTRATOR);
     $admin->description = 'Administrator';
     $auth->add($admin);
     $auth->addChild($admin, $manager);
     $auth->assign($admin, 1);
     Console::output('Success! RBAC roles has been added.');
 }
开发者ID:beaten-sect0r,项目名称:yii2-core,代码行数:25,代码来源:RbacController.php


注:本文中的yii\helpers\Console类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。