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


PHP Console::confirm方法代码示例

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


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

示例1: confirmAction

 /**
  * Confirm action
  * @param string $message message for confirm
  * @param bool $default default selection
  * @throws yii\base\ExitException
  */
 public function confirmAction($message, $default = false)
 {
     if (!Console::confirm($message, $default)) {
         Console::error(Yii::t('activeuser_backend', 'Action canceled'));
         Yii::$app->end();
     }
 }
开发者ID:inblank,项目名称:yii2-activeuser,代码行数:13,代码来源:ConsoleController.php

示例2: actionDropAllTables

 /**
  * Drop all tables in existing DB
  * Use it before Migration
  * @access public
  */
 public function actionDropAllTables()
 {
     if ($this->interactive) {
         if (!Console::confirm('Sure that all tables will be dropped?', false)) {
             $this->stdout("# Canceled. Nothing happened\n", Console::FG_YELLOW);
             return 1;
         }
     }
     $this->_dropTables();
 }
开发者ID:mirkhamidov,项目名称:yii2-console-dbextend,代码行数:15,代码来源:DbexController.php

示例3: 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());
         }
     }
 }
开发者ID:NullRefExcep,项目名称:yii2-cms,代码行数:12,代码来源:Installer.php

示例4: install

 public function install()
 {
     parent::install();
     if (Console::confirm('Create assets files?')) {
         try {
             $this->createFile('@webroot/js/admin/scripts.js');
             echo 'File @webroot/js/admin/scripts.js was created' . PHP_EOL;
             $this->createFile('@webroot/css/admin/main.css');
             echo 'File @webroot/css/admin/main.css was created' . PHP_EOL;
         } catch (\Exception $e) {
             echo $e->getMessage() . PHP_EOL;
         }
     }
 }
开发者ID:NullRefExcep,项目名称:yii2-admin,代码行数:14,代码来源:Installer.php

示例5: saveFounderData

 /**
  * 用户创建交互
  * @param $_model
  * @return mixed
  */
 private function saveFounderData($_model)
 {
     $model = clone $_model;
     $model->username = Console::prompt('请输入创始人用户名', ['default' => 'admin']);
     $model->email = Console::prompt('请输入创始人邮箱', ['default' => 'admin@admin.com']);
     $model->password = Console::prompt('请输入创始人密码', ['default' => 'admin']);
     if (!($user = $model->signup())) {
         Console::output(Console::ansiFormat("\n输入数据验证错误:", [Console::FG_RED]));
         foreach ($model->getErrors() as $k => $v) {
             Console::output(Console::ansiFormat(implode("\n", $v), [Console::FG_RED]));
         }
         if (Console::confirm("\n是否重新创建创始人账户:")) {
             $user = $this->saveFounderData($_model);
         }
     }
     return $user;
 }
开发者ID:rocketyang,项目名称:huajuan,代码行数:22,代码来源:m150106_031824_initUserTable.php

示例6: confirm

 /**
  * Asks user to confirm by typing y or n.
  *
  * @param string $message to echo out before waiting for user input
  * @param boolean $default this value is returned if no selection is made.
  * @return boolean whether user confirmed.
  * Will return true if [[interactive]] is false.
  */
 public function confirm($message, $default = false)
 {
     if ($this->interactive) {
         return Console::confirm($message, $default);
     } else {
         return true;
     }
 }
开发者ID:avron99,项目名称:delayed-orders,代码行数:16,代码来源:Controller.php

示例7: up

 public function up()
 {
     if (Console::confirm('是否生成测试问题数据?', true)) {
         $this->generateFakeData(rand(20, 100));
     }
 }
开发者ID:rocketyang,项目名称:huajuan,代码行数:6,代码来源:m150116_154254_initQuestion.php

示例8: actionMigrate

 public function actionMigrate()
 {
     if (!Console::confirm('Are you sure you want to create sample data. Old data will be lose')) {
         return self::EXIT_CODE_NORMAL;
     }
     $command = Yii::$app->db->createCommand();
     $sampleDir = __DIR__ . '/data';
     // TRUNCATE TABLE
     $command->delete('{{%product_stock}}')->execute();
     $command->delete('{{%gl_detail}}')->execute();
     $command->delete('{{%gl_header}}')->execute();
     $command->delete('{{%goods_movement_dtl}}')->execute();
     $command->delete('{{%goods_movement}}')->execute();
     $command->delete('{{%sales_dtl}}')->execute();
     $command->delete('{{%sales}}')->execute();
     $command->delete('{{%transfer_dtl}}')->execute();
     $command->delete('{{%transfer}}')->execute();
     $command->delete('{{%invoice_dtl}}')->execute();
     $command->delete('{{%invoice}}')->execute();
     $command->delete('{{%payment_dtl}}')->execute();
     $command->delete('{{%payment}}')->execute();
     $command->delete('{{%warehouse}}')->execute();
     $command->delete('{{%branch}}')->execute();
     $command->delete('{{%orgn}}')->execute();
     $command->delete('{{%vendor}}')->execute();
     $command->delete('{{%product_uom}}')->execute();
     $command->delete('{{%cogs}}')->execute();
     $command->delete('{{%price}}')->execute();
     $command->delete('{{%price_category}}')->execute();
     $command->delete('{{%product_child}}')->execute();
     $command->delete('{{%product}}')->execute();
     $command->delete('{{%product_group}}')->execute();
     $command->delete('{{%category}}')->execute();
     $command->delete('{{%uom}}')->execute();
     $command->delete('{{%entri_sheet}}')->execute();
     $command->delete('{{%coa}}')->execute();
     $command->delete('{{%payment_method}}')->execute();
     // orgn
     $rows = (require $sampleDir . '/orgn.php');
     $total = count($rows);
     echo "\ninsert table {{%orgn}}\n";
     Console::startProgress(0, $total);
     foreach ($rows as $i => $row) {
         $command->insert('{{%orgn}}', $this->toAssoc($row, ['id', 'code', 'name']))->execute();
         Console::updateProgress($i + 1, $total);
     }
     $command->resetSequence('{{%orgn}}')->execute();
     Console::endProgress();
     // branch
     $rows = (require $sampleDir . '/branch.php');
     $total = count($rows);
     echo "\ninsert table {{%branch}}\n";
     Console::startProgress(0, $total);
     foreach ($rows as $i => $row) {
         $command->insert('{{%branch}}', $this->toAssoc($row, ['id', 'orgn_id', 'code', 'name']))->execute();
         Console::updateProgress($i + 1, $total);
     }
     $command->resetSequence('{{%branch}}')->execute();
     Console::endProgress();
     // warehouse
     $rows = (require $sampleDir . '/warehouse.php');
     $total = count($rows);
     echo "\ninsert table {{%warehouse}}\n";
     Console::startProgress(0, $total);
     foreach ($rows as $i => $row) {
         $command->insert('{{%warehouse}}', $this->toAssoc($row, ['id', 'code', 'name']))->execute();
         Console::updateProgress($i + 1, $total);
     }
     $command->resetSequence('{{%warehouse}}')->execute();
     Console::endProgress();
     // customer
     $rows = (require $sampleDir . '/vendor.php');
     $total = count($rows);
     echo "\ninsert table {{%vendor}}\n";
     Console::startProgress(0, $total);
     foreach ($rows as $i => $row) {
         $command->insert('{{%vendor}}', $this->toAssoc($row, ['id', 'type', 'code', 'name', 'contact_name', 'contact_number', 'status']))->execute();
         Console::updateProgress($i + 1, $total);
     }
     $command->resetSequence('{{%vendor}}')->execute();
     Console::endProgress();
     // product category
     $rows = (require $sampleDir . '/category.php');
     $total = count($rows);
     echo "\ninsert table {{%category}}\n";
     Console::startProgress(0, $total);
     foreach ($rows as $i => $row) {
         $command->insert('{{%category}}', $this->toAssoc($row, ['id', 'code', 'name']))->execute();
         Console::updateProgress($i + 1, $total);
     }
     $command->resetSequence('{{%category}}')->execute();
     Console::endProgress();
     // product group
     $rows = (require $sampleDir . '/product_group.php');
     $total = count($rows);
     echo "\ninsert table {{%product_group}}\n";
     Console::startProgress(0, $total);
     foreach ($rows as $i => $row) {
         $command->insert('{{%product_group}}', $this->toAssoc($row, ['id', 'code', 'name']))->execute();
         Console::updateProgress($i + 1, $total);
//.........这里部分代码省略.........
开发者ID:sangkil,项目名称:biz3-distro,代码行数:101,代码来源:DataController.php

示例9: actionCreate

 /**
  * Create a user.
  */
 public function actionCreate()
 {
     $groups = Group::find()->disableAccessCheck()->orderBy('name')->all();
     $this->out("Groups");
     $options = [];
     $i = 1;
     $defaultGroup = null;
     foreach ($groups as $group) {
         $extra = '';
         if ($group->system === 'users') {
             $defaultGroup = $group->primaryKey;
             $extra = '*';
         }
         $options[$i] = $group->primaryKey;
         $this->out("{$i}) {$group->descriptor}{$extra}");
         $i++;
     }
     $options[''] = $defaultGroup;
     $group = Console::select("Choose", $options);
     if (empty($group)) {
         $group = $defaultGroup;
     } else {
         $group = $options[$group];
     }
     $user = new User();
     $user->scenario = 'creation';
     $user->first_name = $this->prompt("First name");
     $user->last_name = $this->prompt("Last name");
     $user->email = $this->prompt("Email");
     $user->status = 1;
     $user->username = $this->prompt("Username");
     $user->password = $this->prompt("Password");
     $user->registerRelationModel(['parent_object_id' => $group]);
     if (!$user->validate()) {
         \d($user->errors);
         $this->stderr("User didn't validate!");
         exit;
     }
     $individual = $user->guessIndividual();
     if (empty($individual)) {
         if (!Console::confirm("No matching individual was found. Continue?")) {
             $this->stderr("Bye!");
             exit;
         }
     } elseif (is_object($individual)) {
         $user->object_individual_id = $individual->primaryKey;
         if (!Console::confirm("Matching individual was found ({$individual->descriptor})! Continue?")) {
             $this->stderr("Bye!");
             exit;
         }
     } else {
         $options = [];
         $i = 1;
         $this->out("Possible Individual Matches...");
         foreach ($individual as $ind) {
             $options[$i] = $ind->primaryKey;
             $this->out("{$i}) {$ind->descriptor}");
             $i++;
         }
         $user->object_individual_id = Console::select("Choose", $options);
     }
     if ($user->save()) {
         $this->out("User created!");
     } else {
         \d($user->errors);
         $this->out("Error creating user!");
     }
 }
开发者ID:psesd,项目名称:cascade-lib,代码行数:71,代码来源:UsersController.php

示例10: actionCreate

 /**
  * Create sample data
  */
 public function actionCreate()
 {
     if (!Console::confirm('Are you sure you want to create sample data. Old data will be lose')) {
         return self::EXIT_CODE_NORMAL;
     }
     $command = Yii::$app->db->createCommand();
     $sampleDir = __DIR__ . '/samples/zomb';
     // TRUNCATE TABLE
     $command->delete('{{%product_stock}}')->execute();
     $command->delete('{{%gl_detail}}')->execute();
     $command->delete('{{%gl_header}}')->execute();
     $command->delete('{{%goods_movement_dtl}}')->execute();
     $command->delete('{{%goods_movement}}')->execute();
     $command->delete('{{%sales_dtl}}')->execute();
     $command->delete('{{%sales}}')->execute();
     $command->delete('{{%transfer_dtl}}')->execute();
     $command->delete('{{%transfer}}')->execute();
     $command->delete('{{%invoice_dtl}}')->execute();
     $command->delete('{{%invoice}}')->execute();
     $command->delete('{{%payment_dtl}}')->execute();
     $command->delete('{{%payment}}')->execute();
     $command->delete('{{%warehouse}}')->execute();
     $command->delete('{{%branch}}')->execute();
     $command->delete('{{%orgn}}')->execute();
     $command->delete('{{%vendor}}')->execute();
     $command->delete('{{%product_uom}}')->execute();
     $command->delete('{{%cogs}}')->execute();
     $command->delete('{{%price}}')->execute();
     $command->delete('{{%price_category}}')->execute();
     $command->delete('{{%product_child}}')->execute();
     $command->delete('{{%product}}')->execute();
     $command->delete('{{%product_group}}')->execute();
     $command->delete('{{%category}}')->execute();
     $command->delete('{{%uom}}')->execute();
     $command->delete('{{%entri_sheet}}')->execute();
     $command->delete('{{%coa}}')->execute();
     $command->delete('{{%payment_method}}')->execute();
     // orgn
     $rows = (require $sampleDir . '/orgn.php');
     $total = count($rows);
     echo "\ninsert table {{%orgn}}\n";
     Console::startProgress(0, $total);
     foreach ($rows as $i => $row) {
         $command->insert('{{%orgn}}', $this->toAssoc($row, ['id', 'code', 'name']))->execute();
         Console::updateProgress($i + 1, $total);
     }
     $command->resetSequence('{{%orgn}}')->execute();
     Console::endProgress();
     // branch
     $rows = (require $sampleDir . '/branch.php');
     $total = count($rows);
     echo "\ninsert table {{%branch}}\n";
     Console::startProgress(0, $total);
     foreach ($rows as $i => $row) {
         $command->insert('{{%branch}}', $this->toAssoc($row, ['id', 'orgn_id', 'code', 'name', 'addr']))->execute();
         Console::updateProgress($i + 1, $total);
     }
     $command->resetSequence('{{%branch}}')->execute();
     Console::endProgress();
     // warehouse
     $rows = (require $sampleDir . '/warehouse.php');
     $total = count($rows);
     echo "\ninsert table {{%warehouse}}\n";
     Console::startProgress(0, $total);
     foreach ($rows as $i => $row) {
         $command->insert('{{%warehouse}}', $this->toAssoc($row, ['id', 'code', 'name']))->execute();
         Console::updateProgress($i + 1, $total);
     }
     $command->resetSequence('{{%warehouse}}')->execute();
     Console::endProgress();
     // customer
     $rows = (require $sampleDir . '/vendor.php');
     $total = count($rows);
     echo "\ninsert table {{%vendor}}\n";
     Console::startProgress(0, $total);
     foreach ($rows as $i => $row) {
         $command->insert('{{%vendor}}', $this->toAssoc($row, ['id', 'type', 'code', 'name', 'contact_name', 'contact_number', 'status']))->execute();
         Console::updateProgress($i + 1, $total);
     }
     $command->resetSequence('{{%vendor}}')->execute();
     Console::endProgress();
     // product category
     $rows = (require $sampleDir . '/category.php');
     $total = count($rows);
     echo "\ninsert table {{%category}}\n";
     Console::startProgress(0, $total);
     foreach ($rows as $i => $row) {
         $command->insert('{{%category}}', $this->toAssoc($row, ['id', 'code', 'name']))->execute();
         Console::updateProgress($i + 1, $total);
     }
     $command->resetSequence('{{%category}}')->execute();
     Console::endProgress();
     // product group
     $rows = (require $sampleDir . '/product_group.php');
     $total = count($rows);
     echo "\ninsert table {{%product_group}}\n";
     Console::startProgress(0, $total);
//.........这里部分代码省略.........
开发者ID:sangkil,项目名称:biz3-distro,代码行数:101,代码来源:SampleDataController.php

示例11: load

 /**
  * Load sample
  * @param string $sample
  * @param \yii\db\Command $command
  * @param boolean $confirm
  */
 public function load($sample, $command, $confirm = true)
 {
     $exists = $command->setSql("select count(*) from {{%{$sample}}}")->queryScalar() > 0;
     if (!$exists || $confirm && Console::confirm("Overwrote {$sample}")) {
         $samples = isset($this->_samples[$sample]) ? $this->_samples[$sample] : [];
         $this->resolveRequired($samples, $command);
         $file = $this->sourcePath . "/{$sample}.php";
         $this->internalLoad($file, ['command' => $command, 'faker' => $this->generator, 'now' => new Expression('NOW()')]);
     }
 }
开发者ID:sangkil,项目名称:application,代码行数:16,代码来源:SampleDataController.php

示例12: actionInstall

 public function actionInstall()
 {
     // Determine absolute path
     $root = str_replace('\\', '/', __DIR__);
     preg_match('/.+\\/(?=.+\\/.+$)/', $root, $match);
     $root = $match[0];
     // common/config/main-local.php path
     $main_local = $root . 'common/config/main-local.php';
     if (is_writable($main_local)) {
         $main_local_file = file_get_contents($main_local);
         // Read old values
         preg_match('/(?<=host=).+?(?=;)/', $main_local_file, $default['hostname']);
         preg_match('/(?<=dbname=).+?(?=\',)/', $main_local_file, $default['dbname']);
         preg_match('/(?<=username\' => \').+?(?=\',)/', $main_local_file, $default['username']);
         // Prompt for input
         Console::output("\n" . 'Please specify database connection parameters.' . "\n");
         $config['hostname'] = Console::prompt('Database Hostname', ['default' => $default['hostname'][0]]);
         $config['dbname'] = Console::prompt('Database Name', ['default' => $default['dbname'][0]]);
         $config['username'] = Console::prompt('Database Username', ['default' => $default['username'][0]]);
         $config['password'] = Console::prompt('Database Password []');
         echo "\n";
         // Database Connection
         $db_connection = new \mysqli($config['hostname'], $config['username'], $config['password']);
         if (empty($db_connection->connect_error)) {
             // Write new value
             $main_local_file = preg_replace('/(?<=host=).+?(?=;)/', $config['hostname'], $main_local_file);
             $main_local_file = preg_replace('/(?<=dbname=).+?(?=\',)/', $config['dbname'], $main_local_file);
             $main_local_file = preg_replace('/(?<=username\' => \').+?(?=\',)/', $config['username'], $main_local_file);
             $main_local_file = preg_replace('/(?<=password\' => \').+?(?=\',)/', $config['password'], $main_local_file);
             // Write to file
             file_put_contents($main_local, $main_local_file);
             $import = Console::confirm('Import SQL file ?' . "\n", true);
             if (!empty($import)) {
                 // Import SQL
                 $db_connection->set_charset('utf8');
                 // Read SQL file
                 $sql_file = file_get_contents($root . 'dev/_sql/imagenizer.sql');
                 // Edit Database Name
                 $sql_file = preg_replace('/(?<=CREATE DATABASE IF NOT EXISTS \\`).+?(?=\\`)/', $config['dbname'], $sql_file);
                 $sql_file = preg_replace('/(?<=USE \\`).+?(?=\\`;)/', $config['dbname'], $sql_file);
                 // Skip comments and new lines then concat multi-line SQL into single line and put each line into an array
                 preg_match_all('/^(?!--)\\S.{0,}?;/sm', $sql_file, $sql_line);
                 // Execute each line iteratively (since mysqli::query() cannot execute multiple line at once)
                 foreach ($sql_line[0] as $key => $value) {
                     $db_connection->query($value);
                 }
                 // Setup root account
                 $this->setRoot();
                 // Setup Role Based Access Control
                 $this->setRbac();
             }
             // Close Connections
             $db_connection->close();
         } else {
             if (empty($mute)) {
                 Console::output('Error: Cannot connect to the database.' . "\n");
             }
             exit;
         }
     } else {
         if (empty($mute)) {
             Console::output('Error: The file "' . $main_local . '" is not writable.' . "\n");
         }
         exit;
     }
     if (empty($mute)) {
         Console::output("\n" . 'Imagenizer was installed successfully.' . "\n");
     }
 }
开发者ID:gearger,项目名称:imagenizer,代码行数:69,代码来源:SetupController.php


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