This commit is contained in:
root
2013-05-03 20:18:07 +03:00
10 changed files with 53 additions and 64 deletions

View File

@@ -8,7 +8,6 @@
namespace yii\base;
use Yii;
use yii\helpers\FileHelper;
/**
* Application is the base class for all application classes.

View File

@@ -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:

View File

@@ -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);
}

View File

@@ -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 <qiang.xue@gmail.com>
* @since 2.0
*/
class Logger extends \yii\base\Component
class Logger extends Component
{
/**
* Error message level. An error message is one that indicates the abnormal termination of the

View File

@@ -28,16 +28,16 @@ use yii\base\Application;
* 'preload' => array('log'),
* 'components' => array(
* 'log' => array(
* 'class' => '\yii\logging\Router',
* 'class' => 'yii\logging\Router',
* 'targets' => array(
* 'file' => array(
* 'class' => '\yii\logging\FileTarget',
* 'levels' => 'trace, info',
* 'categories' => 'yii\*',
* 'class' => 'yii\logging\FileTarget',
* 'levels' => array('trace', 'info'),
* 'categories' => array('yii\*'),
* ),
* 'email' => array(
* 'class' => '\yii\logging\EmailTarget',
* 'levels' => 'error, warning',
* 'class' => 'yii\logging\EmailTarget',
* 'levels' => array('error', 'warning'),
* 'emails' => array('admin@example.com'),
* ),
* ),
@@ -73,7 +73,6 @@ class Router extends Component
public function init()
{
parent::init();
foreach ($this->targets as $name => $target) {
if (!$target instanceof Target) {
$this->targets[$name] = Yii::createObject($target);

View File

@@ -71,13 +71,13 @@ class DbSession extends Session
*/
public function init()
{
parent::init();
if (is_string($this->db)) {
$this->db = Yii::$app->getComponent($this->db);
}
if (!$this->db instanceof Connection) {
throw new InvalidConfigException("DbSession::db must be either a DB connection instance or the application component ID of a DB connection.");
}
}
parent::init();
}
/**