本文整理汇总了PHP中yii\helpers\Console::output方法的典型用法代码示例。如果您正苦于以下问题:PHP Console::output方法的具体用法?PHP Console::output怎么用?PHP Console::output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Console
的用法示例。
在下文中一共展示了Console::output方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendMessageAsync
/**
*
* @param \talview\sesmailer\Message $message
*
* @return bool
*/
protected function sendMessageAsync($message)
{
try {
return $this->client->sendRawEmailAsync(['RawMessage' => ['Data' => base64_encode($message->getSwiftMessage())]]);
} catch (SesException $e) {
Console::output($e->getMessage());
Yii::error($e->getMessage());
}
return false;
}
示例2: 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.');
}
示例3: 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.');
}
示例4: 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数据完成 ....');
}
示例5: 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.');
}
示例6: 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.');
}
示例7: 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.');
}
示例8: setExecutable
public function setExecutable($paths)
{
foreach ($paths as $executable) {
$executable = Yii::getAlias($executable);
Console::output("Setting executable: {$executable}");
@chmod($executable, 0755);
}
}
示例9: dropTableIfExist
public function dropTableIfExist($table)
{
if ($this->tableExist($table)) {
return $this->dropTable($table);
} else {
Console::output('Table "' . $table . '" not found');
}
}
示例10: actionCron
public function actionCron()
{
$time = new \DateTime('now');
foreach ($this->getScheduler()->all() as $task) {
if ($this->getScheduler()->handle($task, $time)) {
Console::output("Executed " . $task->getKey());
}
}
}
示例11: export
/**
* @inheritdoc
*/
public function export()
{
foreach ($this->messages as $message) {
if ($message[1] == Logger::LEVEL_ERROR) {
Console::error($this->formatMessage($message));
} else {
Console::output($this->formatMessage($message));
}
}
}
示例12: actionList
public function actionList()
{
Console::output("Currently waiting exports:");
/** @var ActiveQuery $exportRequests */
$requestsQuery = ExportRequest::find()->where(['is_exported' => 0])->orderBy(['created_at' => SORT_ASC]);
foreach ($requestsQuery->each() as $exportRequest) {
/** @var ExportRequest $exportRequest */
Console::output("[#" . $exportRequest->id . ": " . $exportRequest->created_at . "] - " . $exportRequest->data_raw);
}
}
示例13: actionModule
/**
* Установка модуля
*
* - запуск миграций
* - запуск установщика модуля
*
* @param string $module ID модуля
*/
public function actionModule($packageName, $installationPath = null)
{
if (!is_dir($installationPath)) {
$installationPath = FileHelper::normalizePath(Yii::getAlias('@vendor' . '/' . $packageName), '/');
}
$installationFile = $installationPath . '/Install.php';
$basePath = dirname(Yii::getAlias('@vendor'));
$io = new Console();
if (file_exists($installationFile)) {
$io->output("> installation file: " . $installationFile);
$installerClass = (require_once $installationFile);
$installer = new $installerClass(array('yiiConsoleApp' => Yii::$app, 'path' => $installationPath, 'name' => $packageName, 'io' => $io, 'migrationPath' => InstallHelper::getMigrationPath($basePath), 'configPath' => InstallHelper::getYiipConfigPath($basePath) . $packageName));
$installer->install();
$io->output("---");
$io->output("");
} else {
$io->output("> no installation file");
$io->output("");
}
}
示例14: initUserMenu
/**
* 初始化后台用户菜单
*/
public function initUserMenu()
{
Console::output('注册用户模块后台管理菜单 ....');
//用户
Menu::set('user', ['label' => '用户管理', 'url' => ['/admin/user/index'], 'icon' => 'fa-user', 'priority' => 100]);
//rbac
Menu::set('rbac', ['label' => '角色权限', 'icon' => 'fa-group', 'priority' => 100]);
Menu::set('rbac.roles', ['label' => '角色列表', 'url' => ['/admin/role/index'], 'priority' => 101]);
Menu::set('rbac.permissions', ['label' => '权限列表', 'url' => ['/admin/permission/index'], 'priority' => 102]);
Console::output('注册用户模块后台管理菜单完成 ....');
}
示例15: install
public function install()
{
parent::install();
if (Console::confirm('Create upload folder?')) {
try {
$this->createFolder('@webroot/uploads');
Console::output('Folder @webroot/uploads was created');
} catch (\Exception $e) {
Console::output($e->getMessage());
}
}
}