diff --git a/apps/bootstrap/protected/config/main.php b/apps/bootstrap/protected/config/main.php index 96e0986f3b..20b5e7edbd 100644 --- a/apps/bootstrap/protected/config/main.php +++ b/apps/bootstrap/protected/config/main.php @@ -3,6 +3,7 @@ return array( 'id' => 'hello', 'basePath' => dirname(__DIR__), + 'preload' => array('log'), 'components' => array( 'cache' => array( 'class' => 'yii\caching\FileCache', @@ -14,6 +15,15 @@ return array( 'assetManager' => array( 'bundles' => require(__DIR__ . '/assets.php'), ), + 'log' => array( + 'class' => 'yii\logging\Router', + 'targets' => array( + 'file' => array( + 'class' => 'yii\logging\FileTarget', + 'levels' => array('error', 'warning'), + ), + ), + ), ), 'params' => array( 'adminEmail' => 'admin@example.com', diff --git a/apps/bootstrap/protected/views/layouts/main.php b/apps/bootstrap/protected/views/layouts/main.php index 0eaeb99427..1e8a3af571 100644 --- a/apps/bootstrap/protected/views/layouts/main.php +++ b/apps/bootstrap/protected/views/layouts/main.php @@ -1,9 +1,11 @@ registerAssetBundle('app'); ?> beginPage(); ?> @@ -23,7 +25,7 @@ $this->registerAssetBundle('app');
Please fill out the following fields to login:
-beginWidget('yii\widgets\ActiveForm', array('options' => array('class' => 'form-horizontal'))); ?> +beginWidget(ActiveForm::className(), array('options' => array('class' => 'form-horizontal'))); ?> field($model, 'username')->textInput(); ?> field($model, 'password')->passwordInput(); ?> field($model, 'rememberMe')->checkbox(); ?> diff --git a/framework/base/Application.php b/framework/base/Application.php index 5b92f76ed1..ac7cc6aa6a 100644 --- a/framework/base/Application.php +++ b/framework/base/Application.php @@ -8,7 +8,6 @@ namespace yii\base; use Yii; -use yii\helpers\FileHelper; /** * Application is the base class for all application classes. diff --git a/framework/base/Object.php b/framework/base/Object.php index a5479905e0..a90a231794 100644 --- a/framework/base/Object.php +++ b/framework/base/Object.php @@ -14,6 +14,14 @@ namespace yii\base; */ class Object { + /** + * @return string the fully qualified name of this class. + */ + public static function className() + { + return get_called_class(); + } + /** * Constructor. * The default implementation does two things: diff --git a/framework/console/Controller.php b/framework/console/Controller.php index 539bca4195..c07d92df42 100644 --- a/framework/console/Controller.php +++ b/framework/console/Controller.php @@ -36,10 +36,12 @@ class Controller extends \yii\base\Controller public $interactive = true; /** - * @var bool whether to enable ANSI style in output. If not set it will be auto detected. - * Default is disabled on Windows systems and enabled on linux. + * @var bool whether to enable ANSI style in output. + * Setting this will affect [[ansiFormat()]], [[stdout()]] and [[stderr()]]. + * If not set it will be auto detected using [[yii\helpers\Console::streamSupportsAnsiColors()]] with STDOUT + * for [[ansiFormat()]] and [[stdout()]] and STDERR for [[stderr()]]. */ - public $ansi; + public $colors; /** * Runs an action with the specified action ID and parameters. @@ -128,13 +130,13 @@ class Controller extends \yii\base\Controller * * Example: * ~~~ - * $this->formatString('This will be red and underlined.', Console::FG_RED, Console::UNDERLINE); + * $this->ansiFormat('This will be red and underlined.', Console::FG_RED, Console::UNDERLINE); * ~~~ * * @param string $string the string to be formatted * @return string */ - public function formatString($string) + public function ansiFormat($string) { if ($this->ansi === true || $this->ansi === null && Console::streamSupportsAnsiColors(STDOUT)) { $args = func_get_args(); @@ -192,47 +194,6 @@ class Controller extends \yii\base\Controller return fwrite(STDERR, $string); } - /** - * Asks the user for input. Ends when the user types a carriage return (PHP_EOL). Optionally, It also provides a - * prompt. - * - * @param string $prompt the prompt (optional) - * @return string the user's input - */ - public function input($prompt = null) - { - if (isset($prompt)) { - static::stdout($prompt); - } - return static::stdin(); - } - - /** - * Prints text to STDOUT appended with a carriage return (PHP_EOL). - * - * @param string $text - * @param bool $raw - * - * @return mixed Number of bytes printed or bool false on error - */ - public function output($text = null) - { - return static::stdout($text . PHP_EOL); - } - - /** - * Prints text to STDERR appended with a carriage return (PHP_EOL). - * - * @param string $text - * @param bool $raw - * - * @return mixed Number of bytes printed or false on error - */ - public function error($text = null) - { - return static::stderr($text . PHP_EOL); - } - /** * Prompts the user for input and validates it * @@ -248,7 +209,11 @@ class Controller extends \yii\base\Controller */ public function prompt($text, $options = array()) { - return Console::prompt($text, $options); + if ($this->interactive) { + return Console::prompt($text, $options); + } else { + return isset($options['default']) ? $options['default'] : ''; + } } /** @@ -276,7 +241,7 @@ class Controller extends \yii\base\Controller * * @return string An option character the user chose */ - public static function select($prompt, $options = array()) + public function select($prompt, $options = array()) { return Console::select($prompt, $options); } diff --git a/framework/logging/Logger.php b/framework/logging/Logger.php index 607c388419..5c9a89d8b3 100644 --- a/framework/logging/Logger.php +++ b/framework/logging/Logger.php @@ -6,7 +6,9 @@ */ namespace yii\logging; -use yii\base\InvalidConfigException; + +use \yii\base\Component; +use \yii\base\InvalidConfigException; /** * Logger records logged messages in memory. @@ -17,7 +19,7 @@ use yii\base\InvalidConfigException; * @author Qiang Xue