Commit 945c6e6a by Qiang Xue

...

parent 9f716488
<?php
/**
* HttpException class file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\base;
/**
* HttpException represents an exception caused by an improper request of the end-user.
*
* HttpException can be differentiated via its [[statusCode]] property value which
* keeps a standard HTTP status code (e.g. 404, 500). Error handlers may use this status code
* to decide how to format the error page.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class HttpException extends Exception
{
/**
* @var integer HTTP status code, such as 403, 404, 500, etc.
*/
public $statusCode;
/**
* Constructor.
* @param integer $status HTTP status code, such as 404, 500, etc.
* @param string $message error message
* @param integer $code error code
*/
public function __construct($status, $message = null, $code = 0)
{
$this->statusCode = $status;
parent::__construct($message, $code);
}
}
......@@ -393,7 +393,7 @@ abstract class Module extends Component implements Initable
* )
* ~~~
*
* @param array $components application components (id => component configuration or instances)
* @param array $components application components (id => component configuration or instance)
*/
public function setComponents($components)
{
......
<?php
/**
* StatePersister class file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\base;
/**
* CStatePersister implements a file-based persistent data storage.
*
* It can be used to keep data available through multiple requests and sessions.
*
* By default, CStatePersister stores data in a file named 'state.bin' that is located
* under the application {@link CApplication::getRuntimePath runtime path}.
* You may change the location by setting the {@link stateFile} property.
*
* To retrieve the data from CStatePersister, call {@link load()}. To save the data,
* call {@link save()}.
*
* Comparison among state persister, session and cache is as follows:
* <ul>
* <li>session: data persisting within a single user session.</li>
* <li>state persister: data persisting through all requests/sessions (e.g. hit counter).</li>
* <li>cache: volatile and fast storage. It may be used as storage medium for session or state persister.</li>
* </ul>
*
* Since server resource is often limited, be cautious if you plan to use CStatePersister
* to store large amount of data. You should also consider using database-based persister
* to improve the throughput.
*
* CStatePersister is a core application component used to store global application state.
* It may be accessed via {@link CApplication::getStatePersister()}.
* page state persistent method based on cache.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class StatePersister extends ApplicationComponent
{
/**
* @var string the file path for keeping the state data. Make sure the directory containing
* the file exists and is writable by the Web server process. If using relative path, also
* make sure the path is correct. You may use a path alias here. If not set, it defaults
* to the `state.bin` file under the application's runtime directory.
*/
public $dataFile;
/**
* Loads state data from persistent storage.
* @return mixed state data. Null if no state data available.
*/
public function load()
{
$dataFile = \Yii::getAlias($this->dataFile);
if (is_file($dataFile) && ($data = file_get_contents($dataFile)) !== false) {
return unserialize($data);
} else {
return null;
}
}
/**
* Saves application state in persistent storage.
* @param mixed $state state data (must be serializable).
*/
public function save($state)
{
file_put_contents(\Yii::getAlias($this->dataFile), serialize($state), LOCK_EX);
}
}
......@@ -245,7 +245,7 @@ class ActiveFinder extends \yii\base\Object
}
if (is_array($with)) {
foreach ($with as $name => $value) {
if (is_array($value)) {
if (is_array($value) || $value instanceof \Closure) {
$this->buildJoinTree($parent, $name, $value);
} else {
$this->buildJoinTree($parent, $value);
......@@ -299,8 +299,12 @@ class ActiveFinder extends \yii\base\Object
}
}
foreach ($config as $name => $value) {
$child->query->$name = $value;
if ($config instanceof \Closure) {
call_user_func($config, $child->query);
} else {
foreach ($config as $name => $value) {
$child->query->$name = $value;
}
}
return $child;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment