throw new \yii\base\Exception(\Yii::t('yii', 'Application runtime path "{path}" is not valid. Please make sure it is a directory writable by the Web server process.',
array('{path}' => $path)));
if (!is_dir($path) || !is_writable($path)) {
throw new \yii\base\Exception("Application runtime path \"$path\" is invalid. Please make sure it is a directory writable by the Web server process.");
}
$this->_runtimePath = $runtimePath;
$this->_runtimePath = $path;
}
/**
* Returns the root directory that holds all third-party extensions.
* @return string the directory that contains all extensions. Defaults to the 'extensions' directory under 'protected'.
*/
public function getExtensionPath()
{
return \Yii::getPathOfAlias('ext');
}
/**
* Sets the root directory that holds all third-party extensions.
* @param string $path the directory that contains all third-party extensions.
*/
public function setExtensionPath($path)
{
if (($extensionPath = realpath($path)) === false || !is_dir($extensionPath)) {
throw new \yii\base\Exception(\Yii::t('yii', 'Extension path "{path}" does not exist.',
array('{path}' => $path)));
}
\Yii::setAlias('ext', $extensionPath);
}
/**
* Returns the language that the user is using and the application should be targeted to.
* @return string the language that the user is using and the application should be targeted to.
* Defaults to the {@link sourceLanguage source language}.
* Returns the language that the end user is using.
* @return string the language that the user is using (e.g. 'en_US', 'zh_CN').
* Defaults to the value of [[sourceLanguage]].
*/
public function getLanguage()
{
@ -309,13 +229,10 @@ abstract class Application extends Module
}
/**
* Specifies which language the application is targeted to.
*
* This is the language that the application displays to end users.
* If set null, it uses the {@link sourceLanguage source language}.
*
* Unless your application needs to support multiple languages, you should always
* set this language to null to maximize the application's performance.
* Specifies which language the end user is using.
* This is the language that the application should use to display to end users.
* By default, [[language]] and [[sourceLanguage]] are the same.
* Do not set this property unless your application needs to support multiple languages.
* @param string $language the user language (e.g. 'en_US', 'zh_CN').
* If it is null, the {@link sourceLanguage} will be used.
*/
@ -429,7 +346,7 @@ abstract class Application extends Module
/**
* Returns the database connection component.
* @return CDbConnection the database connection
* @return \yii\db\dao\Connection the database connection
*/
public function getDb()
{
@ -438,7 +355,7 @@ abstract class Application extends Module
/**
* Returns the error handler component.
* @return CErrorHandler the error handler application component.
* @return ErrorHandler the error handler application component.
*/
public function getErrorHandler()
{
@ -447,7 +364,7 @@ abstract class Application extends Module
/**
* Returns the security manager component.
* @return CSecurityManager the security manager application component.
* @return SecurityManager the security manager application component.
*/
public function getSecurityManager()
{
@ -465,7 +382,7 @@ abstract class Application extends Module
/**
* Returns the cache component.
* @return CCache the cache application component. Null if the component is not enabled.
* @return \yii\caching\Cache the cache application component. Null if the component is not enabled.
*/
public function getCache()
{
@ -474,7 +391,7 @@ abstract class Application extends Module
/**
* Returns the core message translations component.
* @return CPhpMessageSource the core message translations
* @return \yii\i18n\MessageSource the core message translations
*/
public function getCoreMessages()
{
@ -483,7 +400,7 @@ abstract class Application extends Module
/**
* Returns the application message translations component.
* @return CMessageSource the application message translations
* @return \yii\i18n\MessageSource the application message translations
*/
public function getMessages()
{
@ -492,7 +409,7 @@ abstract class Application extends Module
/**
* Returns the request component.
* @return CHttpRequest the request component
* @return Request the request component
*/
public function getRequest()
{
@ -500,93 +417,6 @@ abstract class Application extends Module
}
/**
* Returns the URL manager component.
* @return CUrlManager the URL manager component
*/
public function getUrlManager()
{
return $this->getComponent('urlManager');
}
/**
* @return CController the currently active controller. Null is returned in this base class.
*/
public function getController()
{
return null;
}
/**
* Creates a relative URL based on the given controller and action information.
* @param string $route the URL route. This should be in the format of 'ControllerID/ActionID'.
* @param array $params additional GET parameters (name=>value). Both the name and value will be URL-encoded.
* @param string $ampersand the token separating name-value pairs in the URL.
* @return string the constructed URL
*/
public function createUrl($route, $params = array(), $ampersand = '&')