From 13ec6756ec03d376e862c6eda5385ec0460bafd6 Mon Sep 17 00:00:00 2001 From: Sergey Makinen Date: Tue, 23 Aug 2016 23:38:14 +0300 Subject: [PATCH] Updates PHPDocs & adds helpers --- .gitignore | 8 +-- Asset.php | 56 +++++++++------- Auth.php | 8 +++ Cache.php | 75 +++++++++++++++++++-- Db.php | 112 +++++++++++++++++--------------- Error.php | 53 ++++++++------- Facade.php | 12 +++- Formatter.php | 72 +++++++++++--------- Http.php | 34 ++++++---- I18n.php | 12 +++- Log.php | 12 +++- Mailer.php | 42 +++++++----- README.md | 151 +++++++++++++++++++++++++++++++++++++++++- Redis.php | 44 ++++++++----- Request.php | 43 +++++++----- Response.php | 177 ++++++++++++++++++++++++++++++++++++++++++-------- Security.php | 40 +++++++----- Session.php | 16 +++-- Url.php | 40 +++++++----- User.php | 64 ++++++++++-------- View.php | 74 +++++++++++---------- composer.json | 2 +- 22 files changed, 805 insertions(+), 342 deletions(-) diff --git a/.gitignore b/.gitignore index 5e55943..635a964 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -.idea +/.idea /vendor -composer.phar -phpunit.phar -/phpunit.xml +/composer.phar +/composer.lock +/phpunit.phar diff --git a/Asset.php b/Asset.php index ddfcb27..0876018 100644 --- a/Asset.php +++ b/Asset.php @@ -1,4 +1,11 @@ get('assetManager') component. * + * @see \yii\web\AssetManager * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. * @method static array behaviors() Returns a list of behaviors that this component should behave as. * @method static null|\yii\base\Behavior detachBehavior(string $name) Detaches a behavior from the component. * @method static detachBehaviors() Detaches all behaviors from the component. * @method static ensureBehaviors() Makes sure that the behaviors declared in [[behaviors()]] are attached to this component. + * @method static callable getAfterCopy() Returns a PHP callback that is called after a sub-directory or file is successfully copied. + * @method static bool getAppendTimestamp() Returns whether to append a timestamp to the URL of every published asset. + * @method static array getAssetMap() Returns mapping from source asset files (keys) to target asset files (values). * @method static string|bool getAssetPath(\yii\web\AssetBundle $bundle, string $asset) Returns the actual file path for the specified asset. * @method static string getAssetUrl(\yii\web\AssetBundle $bundle, string $asset) Returns the actual URL for the specified asset. + * @method static string getBasePath() Returns the root directory storing the published asset files. + * @method static string getBaseUrl() Returns the base URL through which the published asset files can be accessed. + * @method static callable getBeforeCopy() Returns a PHP callback that is called before copying each sub-directory or file. * @method static null|\yii\base\Behavior getBehavior(string $name) Returns the named behavior object. * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. * @method static \yii\web\AssetBundle getBundle(string $name, bool $publish = true) Returns the named asset bundle. + * @method static array|bool getBundles() Returns list of asset bundle configurations. * @method static \yii\web\AssetConverterInterface getConverter() Returns the asset converter. + * @method static int getDirMode() Returns the permission to be set for newly generated asset directories. + * @method static int getFileMode() Returns the permission to be set for newly published asset files. + * @method static bool getForceCopy() Returns whether the directory being published should be copied even if it is found in the target directory. + * @method static callable getHashCallback() Returns a callback that will be called to produce hash for asset directory generation. + * @method static bool getLinkAssets() Returns whether to use symbolic link to publish asset files. * @method static string|bool getPublishedPath(string $path) Returns the published path of a file path. * @method static string|bool getPublishedUrl(string $path) Returns the URL of a published file path. - * @method static callable getAfterCopy() Returns $afterCopy - a PHP callback that is called after a sub-directory or file is successfully copied. - * @method static bool getAppendTimestamp() Returns $appendTimestamp - whether to append a timestamp to the URL of every published asset. - * @method static array getAssetMap() Returns $assetMap - mapping from source asset files (keys) to target asset files (values). - * @method static string getBasePath() Returns $basePath - the root directory storing the published asset files. - * @method static string getBaseUrl() Returns $baseUrl - the base URL through which the published asset files can be accessed. - * @method static callable getBeforeCopy() Returns $beforeCopy - a PHP callback that is called before copying each sub-directory or file. - * @method static array|bool getBundles() Returns $bundles - list of asset bundle configurations. - * @method static int getDirMode() Returns $dirMode - the permission to be set for newly generated asset directories. - * @method static int getFileMode() Returns $fileMode - the permission to be set for newly published asset files. - * @method static bool getForceCopy() Returns $forceCopy - whether the directory being published should be copied even if it is found in the target directory. - * @method static callable getHashCallback() Returns $hashCallback - a callback that will be called to produce hash for asset directory generation. - * @method static bool getLinkAssets() Returns $linkAssets - whether to use symbolic link to publish asset files. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. * @method static on(string $name, callable $handler, mixed $data = null, bool $append = true) Attaches an event handler to an event. * @method static array publish(string $path, array $options = []) Publishes a file or a directory. + * @method static setAfterCopy(callable $value) Sets a PHP callback that is called after a sub-directory or file is successfully copied. + * @method static setAppendTimestamp(bool $value) Sets whether to append a timestamp to the URL of every published asset. + * @method static setAssetMap(array $value) Sets mapping from source asset files (keys) to target asset files (values). + * @method static setBasePath(string $value) Sets the root directory storing the published asset files. + * @method static setBaseUrl(string $value) Sets the base URL through which the published asset files can be accessed. + * @method static setBeforeCopy(callable $value) Sets a PHP callback that is called before copying each sub-directory or file. + * @method static setBundles(array|bool $value) Sets list of asset bundle configurations. * @method static setConverter(array|\yii\web\AssetConverterInterface $value) Sets the asset converter. - * @method static setAfterCopy(callable $value) Sets $afterCopy - a PHP callback that is called after a sub-directory or file is successfully copied. - * @method static setAppendTimestamp(bool $value) Sets $appendTimestamp - whether to append a timestamp to the URL of every published asset. - * @method static setAssetMap(array $value) Sets $assetMap - mapping from source asset files (keys) to target asset files (values). - * @method static setBasePath(string $value) Sets $basePath - the root directory storing the published asset files. - * @method static setBaseUrl(string $value) Sets $baseUrl - the base URL through which the published asset files can be accessed. - * @method static setBeforeCopy(callable $value) Sets $beforeCopy - a PHP callback that is called before copying each sub-directory or file. - * @method static setBundles(array|bool $value) Sets $bundles - list of asset bundle configurations. - * @method static setDirMode(int $value) Sets $dirMode - the permission to be set for newly generated asset directories. - * @method static setFileMode(int $value) Sets $fileMode - the permission to be set for newly published asset files. - * @method static setForceCopy(bool $value) Sets $forceCopy - whether the directory being published should be copied even if it is found in the target directory. - * @method static setHashCallback(callable $value) Sets $hashCallback - a callback that will be called to produce hash for asset directory generation. - * @method static setLinkAssets(bool $value) Sets $linkAssets - whether to use symbolic link to publish asset files. + * @method static setDirMode(int $value) Sets the permission to be set for newly generated asset directories. + * @method static setFileMode(int $value) Sets the permission to be set for newly published asset files. + * @method static setForceCopy(bool $value) Sets whether the directory being published should be copied even if it is found in the target directory. + * @method static setHashCallback(callable $value) Sets a callback that will be called to produce hash for asset directory generation. + * @method static setLinkAssets(bool $value) Sets whether to use symbolic link to publish asset files. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. */ class Asset extends Facade diff --git a/Auth.php b/Auth.php index d8cb48d..f14a5fd 100644 --- a/Auth.php +++ b/Auth.php @@ -1,4 +1,11 @@ get('auth') component. * + * @see \yii\rbac\ManagerInterface * @method static bool add(\yii\rbac\Role|\yii\rbac\Permission|\yii\rbac\Rule $object) Adds a role, permission or rule to the RBAC system. * @method static bool addChild(\yii\rbac\Item $parent, \yii\rbac\Item $child) Adds an item as a child of another item. * @method static \yii\rbac\Assignment assign(\yii\rbac\Role $role, string|int $userId) Assigns a role to a user. diff --git a/Cache.php b/Cache.php index e9224c1..9e8e297 100644 --- a/Cache.php +++ b/Cache.php @@ -1,4 +1,11 @@ get('cache') component. * + * @see \yii\caching\Cache * @method static bool add(mixed $key, mixed $value, int $duration = 0, \yii\caching\Dependency $dependency = null) Stores a value identified by a key into cache if the cache does not contain this key. * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. @@ -19,11 +27,10 @@ * @method static ensureBehaviors() Makes sure that the behaviors declared in [[behaviors()]] are attached to this component. * @method static bool exists(mixed $key) Checks whether a specified key exists in the cache. * @method static bool flush() Deletes all values from cache. - * @method static mixed get(mixed $key) Retrieves a value from cache with a specified key. * @method static null|\yii\base\Behavior getBehavior(string $name) Returns the named behavior object. * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. - * @method static string getKeyPrefix() Returns $keyPrefix - a string prefixed to every cache key so that it is unique globally in the whole cache storage. - * @method static array|bool getSerializer() Returns $serializer - the functions used to serialize and unserialize cached data. + * @method static string getKeyPrefix() Returns a string prefixed to every cache key so that it is unique globally in the whole cache storage. + * @method static array|bool getSerializer() Returns the functions used to serialize and unserialize cached data. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static bool madd(array $items, int $duration = 0, \yii\caching\Dependency $dependency = null) Stores multiple items in cache. * @method static array mget(string[] $keys) Retrieves multiple values from cache with the specified keys. @@ -34,8 +41,8 @@ * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. * @method static on(string $name, callable $handler, mixed $data = null, bool $append = true) Attaches an event handler to an event. * @method static bool set(mixed $key, mixed $value, int $duration = 0, \yii\caching\Dependency $dependency = null) Stores a value identified by a key into cache. - * @method static setKeyPrefix(string $value) Sets $keyPrefix - a string prefixed to every cache key so that it is unique globally in the whole cache storage. - * @method static setSerializer(array|bool $value) Sets $serializer - the functions used to serialize and unserialize cached data. + * @method static setKeyPrefix(string $value) Sets a string prefixed to every cache key so that it is unique globally in the whole cache storage. + * @method static setSerializer(array|bool $value) Sets the functions used to serialize and unserialize cached data. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. */ class Cache extends Facade @@ -47,4 +54,62 @@ public static function getFacadeComponentId() { return 'cache'; } + + /** + * Retrieves a value from cache with a specified key. + * + * @param mixed $key a key identifying the cached value. This can be a simple string or + * a complex data structure consisting of factors representing the key. + * @param callable|mixed $default a default value. This can also be any callable function that + * will recieve the key and should return a value. + * + * @return mixed the value stored in cache or the default value if the value is not in the cache, expired, + * or the dependency associated with the cached data has changed. + */ + public static function get($key, $default = false) + { + $value = static::getFacadeComponent()->get($key); + if ($value === false) { + if ($default instanceof \Closure) { + $value = call_user_func($default, $key); + } else { + $value = $default; + } + } + return $value; + } + + /** + * Retrieves a value from cache (or stores it if it's not cached) with a specified key. + * If the cache already contains such a key, it will be returned, else the default value + * will be stored in the cache and returned. + * + * @param mixed $key a key identifying the cached value. This can be a simple string or + * a complex data structure consisting of factors representing the key. + * @param callable|mixed $default the value to be cached and retrieved if some value is not already in the cache. This can also be + * any callable function that will recieve the key and should return a value. + * @param int $duration the number of seconds in which the cached value will expire. 0 means never expire. + * @param \yii\caching\Dependency $dependency dependency of the cached item. If the dependency changes, + * the corresponding value in the cache will be invalidated when it is fetched via [[get()]]. + * This parameter is ignored if [[serializer]] is false. + * + * @return bool whether the value is successfully stored into cache + */ + public static function getOrSet($key, $default, $duration = 0, $dependency = null) + { + /** + * @var \yii\caching\Cache $cache + */ + $cache = static::getFacadeComponent(); + $value = $cache->get($key); + if ($value === false) { + if ($default instanceof \Closure) { + $value = call_user_func($default, $key); + } else { + $value = $default; + } + $cache->set($key, $value, $duration, $dependency); + } + return $value; + } } diff --git a/Db.php b/Db.php index 0469437..df238bd 100644 --- a/Db.php +++ b/Db.php @@ -1,4 +1,11 @@ get('db') component. * + * @see \yii\db\Connection * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. * @method static \yii\db\Transaction beginTransaction(string|null $isolationLevel = null) Starts a transaction. @@ -18,45 +26,45 @@ * @method static null|\yii\base\Behavior detachBehavior(string $name) Detaches a behavior from the component. * @method static detachBehaviors() Detaches all behaviors from the component. * @method static ensureBehaviors() Makes sure that the behaviors declared in [[behaviors()]] are attached to this component. + * @method static array getAttributes() Returns PDO attributes (name => value) that should be set when calling [[open()]] to establish a DB connection. * @method static null|\yii\base\Behavior getBehavior(string $name) Returns the named behavior object. * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. + * @method static string getCharset() Returns the charset used for database connection. + * @method static string getCommandClass() Returns the class used to create new database [[Command]] objects. * @method static string getDriverName() Returns the name of the DB driver. + * @method static string getDsn() Returns the Data Source Name, or DSN, contains the information required to connect to the database. + * @method static bool getEmulatePrepare() Returns whether to turn on prepare emulation. + * @method static bool getEnableQueryCache() Returns whether to enable query caching. + * @method static bool getEnableSavepoint() Returns whether to enable [savepoint](http://en.wikipedia.org/wiki/Savepoint). + * @method static bool getEnableSchemaCache() Returns whether to enable schema caching. + * @method static bool getEnableSlaves() Returns whether to enable read/write splitting by using [[slaves]] to read data. * @method static bool getIsActive() Returns a value indicating whether the DB connection is established. * @method static string getLastInsertID(string $sequenceName = '') Returns the ID of the last inserted row or sequence value. + * @method static array getMasterConfig() Returns the configuration that should be merged with every master configuration listed in [[masters]]. * @method static \PDO getMasterPdo() Returns the PDO instance for the currently active master connection. + * @method static array getMasters() Returns list of master connection configurations. + * @method static string getPassword() Returns the password for establishing DB connection. + * @method static \PDO getPdo() Returns the PHP PDO instance associated with this DB connection. + * @method static string getPdoClass() Returns Custom PDO wrapper class. * @method static \yii\db\QueryBuilder getQueryBuilder() Returns the query builder for the current DB connection. + * @method static \yii\caching\Cache|string getQueryCache() Returns the cache object or the ID of the cache application component that is used for query caching. + * @method static int getQueryCacheDuration() Returns the default number of seconds that query results can remain valid in cache. * @method static array getQueryCacheInfo(int $duration, \yii\caching\Dependency $dependency) Returns the current query cache information. * @method static \yii\db\Schema getSchema() Returns the schema information for the database opened by this connection. + * @method static \yii\caching\Cache|string getSchemaCache() Returns the cache object or the ID of the cache application component that is used to cache the table metadata. + * @method static int getSchemaCacheDuration() Returns number of seconds that table metadata can remain valid in cache. + * @method static array getSchemaCacheExclude() Returns list of tables whose metadata should NOT be cached. + * @method static array getSchemaMap() Returns mapping between PDO driver names and [[Schema]] classes. + * @method static int getServerRetryInterval() Returns the retry interval in seconds for dead servers listed in [[masters]] and [[slaves]]. + * @method static \yii\caching\Cache|string getServerStatusCache() Returns the cache object or the ID of the cache application component that is used to store the health status of the DB servers specified in [[masters]] and [[slaves]]. * @method static \yii\db\Connection getSlave(bool $fallbackToMaster = true) Returns the currently active slave connection. + * @method static array getSlaveConfig() Returns the configuration that should be merged with every slave configuration listed in [[slaves]]. * @method static \PDO getSlavePdo(bool $fallbackToMaster = true) Returns the PDO instance for the currently active slave connection. + * @method static array getSlaves() Returns list of slave connection configurations. + * @method static string getTablePrefix() Returns the common prefix or suffix for table names. * @method static \yii\db\TableSchema getTableSchema(string $name, bool $refresh = false) Obtains the schema information for the named table. * @method static \yii\db\Transaction getTransaction() Returns the currently active transaction. - * @method static array getAttributes() Returns $attributes - PDO attributes (name => value) that should be set when calling [[open()]] to establish a DB connection. - * @method static string getCharset() Returns $charset - the charset used for database connection. - * @method static string getCommandClass() Returns $commandClass - the class used to create new database [[Command]] objects. - * @method static string getDsn() Returns $dsn - the Data Source Name, or DSN, contains the information required to connect to the database. - * @method static bool getEmulatePrepare() Returns $emulatePrepare - whether to turn on prepare emulation. - * @method static bool getEnableQueryCache() Returns $enableQueryCache - whether to enable query caching. - * @method static bool getEnableSavepoint() Returns $enableSavepoint - whether to enable [savepoint](http://en.wikipedia.org/wiki/Savepoint). - * @method static bool getEnableSchemaCache() Returns $enableSchemaCache - whether to enable schema caching. - * @method static bool getEnableSlaves() Returns $enableSlaves - whether to enable read/write splitting by using [[slaves]] to read data. - * @method static array getMasterConfig() Returns $masterConfig - the configuration that should be merged with every master configuration listed in [[masters]]. - * @method static array getMasters() Returns $masters - list of master connection configurations. - * @method static string getPassword() Returns $password - the password for establishing DB connection. - * @method static \PDO getPdo() Returns $pdo - the PHP PDO instance associated with this DB connection. - * @method static string getPdoClass() Returns $pdoClass - Custom PDO wrapper class. - * @method static \yii\caching\Cache|string getQueryCache() Returns $queryCache - the cache object or the ID of the cache application component that is used for query caching. - * @method static int getQueryCacheDuration() Returns $queryCacheDuration - the default number of seconds that query results can remain valid in cache. - * @method static \yii\caching\Cache|string getSchemaCache() Returns $schemaCache - the cache object or the ID of the cache application component that is used to cache the table metadata. - * @method static int getSchemaCacheDuration() Returns $schemaCacheDuration - number of seconds that table metadata can remain valid in cache. - * @method static array getSchemaCacheExclude() Returns $schemaCacheExclude - list of tables whose metadata should NOT be cached. - * @method static array getSchemaMap() Returns $schemaMap - mapping between PDO driver names and [[Schema]] classes. - * @method static int getServerRetryInterval() Returns $serverRetryInterval - the retry interval in seconds for dead servers listed in [[masters]] and [[slaves]]. - * @method static \yii\caching\Cache|string getServerStatusCache() Returns $serverStatusCache - the cache object or the ID of the cache application component that is used to store the health status of the DB servers specified in [[masters]] and [[slaves]]. - * @method static array getSlaveConfig() Returns $slaveConfig - the configuration that should be merged with every slave configuration listed in [[slaves]]. - * @method static array getSlaves() Returns $slaves - list of slave connection configurations. - * @method static string getTablePrefix() Returns $tablePrefix - the common prefix or suffix for table names. - * @method static string getUsername() Returns $username - the username for establishing DB connection. + * @method static string getUsername() Returns the username for establishing DB connection. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static mixed noCache(callable $callable) Disables query cache temporarily. * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. @@ -66,33 +74,33 @@ * @method static string quoteSql(string $sql) Processes a SQL statement by quoting table and column names that are enclosed within double brackets. * @method static string quoteTableName(string $name) Quotes a table name for use in a query. * @method static string quoteValue(string $value) Quotes a string value for use in a query. + * @method static setAttributes(array $value) Sets PDO attributes (name => value) that should be set when calling [[open()]] to establish a DB connection. + * @method static setCharset(string $value) Sets the charset used for database connection. + * @method static setCommandClass(string $value) Sets the class used to create new database [[Command]] objects. * @method static setDriverName(string $driverName) Changes the current driver name. - * @method static setAttributes(array $value) Sets $attributes - PDO attributes (name => value) that should be set when calling [[open()]] to establish a DB connection. - * @method static setCharset(string $value) Sets $charset - the charset used for database connection. - * @method static setCommandClass(string $value) Sets $commandClass - the class used to create new database [[Command]] objects. - * @method static setDsn(string $value) Sets $dsn - the Data Source Name, or DSN, contains the information required to connect to the database. - * @method static setEmulatePrepare(bool $value) Sets $emulatePrepare - whether to turn on prepare emulation. - * @method static setEnableQueryCache(bool $value) Sets $enableQueryCache - whether to enable query caching. - * @method static setEnableSavepoint(bool $value) Sets $enableSavepoint - whether to enable [savepoint](http://en.wikipedia.org/wiki/Savepoint). - * @method static setEnableSchemaCache(bool $value) Sets $enableSchemaCache - whether to enable schema caching. - * @method static setEnableSlaves(bool $value) Sets $enableSlaves - whether to enable read/write splitting by using [[slaves]] to read data. - * @method static setMasterConfig(array $value) Sets $masterConfig - the configuration that should be merged with every master configuration listed in [[masters]]. - * @method static setMasters(array $value) Sets $masters - list of master connection configurations. - * @method static setPassword(string $value) Sets $password - the password for establishing DB connection. - * @method static setPdo(\PDO $value) Sets $pdo - the PHP PDO instance associated with this DB connection. - * @method static setPdoClass(string $value) Sets $pdoClass - Custom PDO wrapper class. - * @method static setQueryCache(\yii\caching\Cache|string $value) Sets $queryCache - the cache object or the ID of the cache application component that is used for query caching. - * @method static setQueryCacheDuration(int $value) Sets $queryCacheDuration - the default number of seconds that query results can remain valid in cache. - * @method static setSchemaCache(\yii\caching\Cache|string $value) Sets $schemaCache - the cache object or the ID of the cache application component that is used to cache the table metadata. - * @method static setSchemaCacheDuration(int $value) Sets $schemaCacheDuration - number of seconds that table metadata can remain valid in cache. - * @method static setSchemaCacheExclude(array $value) Sets $schemaCacheExclude - list of tables whose metadata should NOT be cached. - * @method static setSchemaMap(array $value) Sets $schemaMap - mapping between PDO driver names and [[Schema]] classes. - * @method static setServerRetryInterval(int $value) Sets $serverRetryInterval - the retry interval in seconds for dead servers listed in [[masters]] and [[slaves]]. - * @method static setServerStatusCache(\yii\caching\Cache|string $value) Sets $serverStatusCache - the cache object or the ID of the cache application component that is used to store the health status of the DB servers specified in [[masters]] and [[slaves]]. - * @method static setSlaveConfig(array $value) Sets $slaveConfig - the configuration that should be merged with every slave configuration listed in [[slaves]]. - * @method static setSlaves(array $value) Sets $slaves - list of slave connection configurations. - * @method static setTablePrefix(string $value) Sets $tablePrefix - the common prefix or suffix for table names. - * @method static setUsername(string $value) Sets $username - the username for establishing DB connection. + * @method static setDsn(string $value) Sets the Data Source Name, or DSN, contains the information required to connect to the database. + * @method static setEmulatePrepare(bool $value) Sets whether to turn on prepare emulation. + * @method static setEnableQueryCache(bool $value) Sets whether to enable query caching. + * @method static setEnableSavepoint(bool $value) Sets whether to enable [savepoint](http://en.wikipedia.org/wiki/Savepoint). + * @method static setEnableSchemaCache(bool $value) Sets whether to enable schema caching. + * @method static setEnableSlaves(bool $value) Sets whether to enable read/write splitting by using [[slaves]] to read data. + * @method static setMasterConfig(array $value) Sets the configuration that should be merged with every master configuration listed in [[masters]]. + * @method static setMasters(array $value) Sets list of master connection configurations. + * @method static setPassword(string $value) Sets the password for establishing DB connection. + * @method static setPdo(\PDO $value) Sets the PHP PDO instance associated with this DB connection. + * @method static setPdoClass(string $value) Sets Custom PDO wrapper class. + * @method static setQueryCache(\yii\caching\Cache|string $value) Sets the cache object or the ID of the cache application component that is used for query caching. + * @method static setQueryCacheDuration(int $value) Sets the default number of seconds that query results can remain valid in cache. + * @method static setSchemaCache(\yii\caching\Cache|string $value) Sets the cache object or the ID of the cache application component that is used to cache the table metadata. + * @method static setSchemaCacheDuration(int $value) Sets number of seconds that table metadata can remain valid in cache. + * @method static setSchemaCacheExclude(array $value) Sets list of tables whose metadata should NOT be cached. + * @method static setSchemaMap(array $value) Sets mapping between PDO driver names and [[Schema]] classes. + * @method static setServerRetryInterval(int $value) Sets the retry interval in seconds for dead servers listed in [[masters]] and [[slaves]]. + * @method static setServerStatusCache(\yii\caching\Cache|string $value) Sets the cache object or the ID of the cache application component that is used to store the health status of the DB servers specified in [[masters]] and [[slaves]]. + * @method static setSlaveConfig(array $value) Sets the configuration that should be merged with every slave configuration listed in [[slaves]]. + * @method static setSlaves(array $value) Sets list of slave connection configurations. + * @method static setTablePrefix(string $value) Sets the common prefix or suffix for table names. + * @method static setUsername(string $value) Sets the username for establishing DB connection. * @method static mixed transaction(callable $callback, string|null $isolationLevel = null) Executes callback provided in a transaction. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. * @method static mixed useMaster(callable $callback) Executes the provided callback by using the master connection. diff --git a/Error.php b/Error.php index b0a38a9..a62f50c 100644 --- a/Error.php +++ b/Error.php @@ -1,4 +1,11 @@ get('errorHandler') component. * + * @see \yii\console\ErrorHandler + * @see \yii\web\ErrorHandler * @method static string addTypeLinks(string $code) Adds informational links to the given PHP type/class. * @method static string argumentsToString(array $args) Converts arguments array to its string representation. * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. @@ -24,18 +33,18 @@ * @method static ensureBehaviors() Makes sure that the behaviors declared in [[behaviors()]] are attached to this component. * @method static null|\yii\base\Behavior getBehavior(string $name) Returns the named behavior object. * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. + * @method static string getCallStackItemView() Returns the path of the view file for rendering exceptions and errors call stack element. + * @method static bool getDiscardExistingOutput() Returns whether to discard any existing page output before error display. + * @method static array getDisplayVars() Returns list of the PHP predefined variables that should be displayed on the error page. + * @method static string getErrorAction() Returns the route (e.g. 'site/error') to the controller action that will be used to display external errors. + * @method static string getErrorView() Returns the path of the view file for rendering exceptions without call stack information. + * @method static \Exception getException() Returns the exception that is being handled currently. * @method static string getExceptionName(\Exception $exception) Returns human-readable exception name. - * @method static string getCallStackItemView() Returns $callStackItemView - the path of the view file for rendering exceptions and errors call stack element. - * @method static bool getDiscardExistingOutput() Returns $discardExistingOutput - whether to discard any existing page output before error display. - * @method static array getDisplayVars() Returns $displayVars - list of the PHP predefined variables that should be displayed on the error page. - * @method static string getErrorAction() Returns $errorAction - the route (e.g. 'site/error') to the controller action that will be used to display external errors. - * @method static string getErrorView() Returns $errorView - the path of the view file for rendering exceptions without call stack information. - * @method static \Exception getException() Returns $exception - the exception that is being handled currently. - * @method static string getExceptionView() Returns $exceptionView - the path of the view file for rendering exceptions. - * @method static int getMaxSourceLines() Returns $maxSourceLines - maximum number of source code lines to be displayed. - * @method static int getMaxTraceSourceLines() Returns $maxTraceSourceLines - maximum number of trace source code lines to be displayed. - * @method static int getMemoryReserveSize() Returns $memoryReserveSize - the size of the reserved memory. - * @method static string getPreviousExceptionView() Returns $previousExceptionView - the path of the view file for rendering previous exceptions. + * @method static string getExceptionView() Returns the path of the view file for rendering exceptions. + * @method static int getMaxSourceLines() Returns maximum number of source code lines to be displayed. + * @method static int getMaxTraceSourceLines() Returns maximum number of trace source code lines to be displayed. + * @method static int getMemoryReserveSize() Returns the size of the reserved memory. + * @method static string getPreviousExceptionView() Returns the path of the view file for rendering previous exceptions. * @method static bool handleError(int $code, string $message, string $file, int $line) Handles PHP execution errors such as warnings and notices. * @method static handleException(\Exception $exception) Handles uncaught PHP exceptions. * @method static handleFatalError() Handles fatal PHP errors. @@ -51,17 +60,17 @@ * @method static string renderFile(string $_file_, array $_params_) Renders a view file as a PHP script. * @method static string renderPreviousExceptions(\Exception $exception) Renders the previous exception stack for a given Exception. * @method static string renderRequest() Renders the global variables of the request. - * @method static setCallStackItemView(string $value) Sets $callStackItemView - the path of the view file for rendering exceptions and errors call stack element. - * @method static setDiscardExistingOutput(bool $value) Sets $discardExistingOutput - whether to discard any existing page output before error display. - * @method static setDisplayVars(array $value) Sets $displayVars - list of the PHP predefined variables that should be displayed on the error page. - * @method static setErrorAction(string $value) Sets $errorAction - the route (e.g. 'site/error') to the controller action that will be used to display external errors. - * @method static setErrorView(string $value) Sets $errorView - the path of the view file for rendering exceptions without call stack information. - * @method static setException(\Exception $value) Sets $exception - the exception that is being handled currently. - * @method static setExceptionView(string $value) Sets $exceptionView - the path of the view file for rendering exceptions. - * @method static setMaxSourceLines(int $value) Sets $maxSourceLines - maximum number of source code lines to be displayed. - * @method static setMaxTraceSourceLines(int $value) Sets $maxTraceSourceLines - maximum number of trace source code lines to be displayed. - * @method static setMemoryReserveSize(int $value) Sets $memoryReserveSize - the size of the reserved memory. - * @method static setPreviousExceptionView(string $value) Sets $previousExceptionView - the path of the view file for rendering previous exceptions. + * @method static setCallStackItemView(string $value) Sets the path of the view file for rendering exceptions and errors call stack element. + * @method static setDiscardExistingOutput(bool $value) Sets whether to discard any existing page output before error display. + * @method static setDisplayVars(array $value) Sets list of the PHP predefined variables that should be displayed on the error page. + * @method static setErrorAction(string $value) Sets the route (e.g. 'site/error') to the controller action that will be used to display external errors. + * @method static setErrorView(string $value) Sets the path of the view file for rendering exceptions without call stack information. + * @method static setException(\Exception $value) Sets the exception that is being handled currently. + * @method static setExceptionView(string $value) Sets the path of the view file for rendering exceptions. + * @method static setMaxSourceLines(int $value) Sets maximum number of source code lines to be displayed. + * @method static setMaxTraceSourceLines(int $value) Sets maximum number of trace source code lines to be displayed. + * @method static setMemoryReserveSize(int $value) Sets the size of the reserved memory. + * @method static setPreviousExceptionView(string $value) Sets the path of the view file for rendering previous exceptions. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. * @method static unregister() Unregisters this error handler by restoring the PHP error and exception handlers. */ diff --git a/Facade.php b/Facade.php index 8462592..84d0a7c 100644 --- a/Facade.php +++ b/Facade.php @@ -1,4 +1,11 @@ get('formatter') component. * + * @see \yii\i18n\Formatter * @method static string asBoolean(mixed $value) Formats the value as a boolean. * @method static string asCurrency(mixed $value, string $currency = null, array $options = [], array $textOptions = []) Formats the value as a currency number. * @method static string asDate(int|string|\DateTime $value, string $format = null) Formats the value as a date. @@ -41,41 +49,41 @@ * @method static string format(mixed $value, string|array $format) Formats the value based on the given format type. * @method static null|\yii\base\Behavior getBehavior(string $name) Returns the named behavior object. * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. - * @method static array getBooleanFormat() Returns $booleanFormat - the text to be displayed when formatting a boolean value. - * @method static \IntlCalendar|int|null getCalendar() Returns $calendar - the calendar to be used for date formatting. - * @method static string getCurrencyCode() Returns $currencyCode - the 3-letter ISO 4217 currency code indicating the default currency to use for [[asCurrency]]. - * @method static string getDateFormat() Returns $dateFormat - the default format string to be used to format a [[asDate()|date]]. - * @method static string getDatetimeFormat() Returns $datetimeFormat - the default format string to be used to format a [[asDatetime()|date and time]]. - * @method static string getDecimalSeparator() Returns $decimalSeparator - the character displayed as the decimal point when formatting a number. - * @method static string getDefaultTimeZone() Returns $defaultTimeZone - the time zone that is assumed for input values if they do not include a time zone explicitly. - * @method static string getLocale() Returns $locale - the locale ID that is used to localize the date and number formatting. - * @method static string getNullDisplay() Returns $nullDisplay - the text to be displayed when formatting a `null` value. - * @method static array getNumberFormatterOptions() Returns $numberFormatterOptions - a list of name value pairs that are passed to the intl [Numberformatter::setAttribute()](http://php.net/manual/en/numberformatter.setattribute.php) method of all the number formatter objects created by [[createNumberFormatter()]]. - * @method static array getNumberFormatterSymbols() Returns $numberFormatterSymbols - a list of name value pairs that are passed to the intl [Numberformatter::setSymbol()](http://php.net/manual/en/numberformatter.setsymbol.php) method of all the number formatter objects created by [[createNumberFormatter()]]. - * @method static array getNumberFormatterTextOptions() Returns $numberFormatterTextOptions - a list of name value pairs that are passed to the intl [Numberformatter::setTextAttribute()](http://php.net/manual/en/numberformatter.settextattribute.php) method of all the number formatter objects created by [[createNumberFormatter()]]. - * @method static int getSizeFormatBase() Returns $sizeFormatBase - the base at which a kilobyte is calculated (1000 or 1024 bytes per kilobyte), used by [[asSize]] and [[asShortSize]]. - * @method static string getThousandSeparator() Returns $thousandSeparator - the character displayed as the thousands separator (also called grouping separator) character when formatting a number. - * @method static string getTimeFormat() Returns $timeFormat - the default format string to be used to format a [[asTime()|time]]. - * @method static string getTimeZone() Returns $timeZone - the time zone to use for formatting time and date values. + * @method static array getBooleanFormat() Returns the text to be displayed when formatting a boolean value. + * @method static \IntlCalendar|int|null getCalendar() Returns the calendar to be used for date formatting. + * @method static string getCurrencyCode() Returns the 3-letter ISO 4217 currency code indicating the default currency to use for [[asCurrency]]. + * @method static string getDateFormat() Returns the default format string to be used to format a [[asDate()|date]]. + * @method static string getDatetimeFormat() Returns the default format string to be used to format a [[asDatetime()|date and time]]. + * @method static string getDecimalSeparator() Returns the character displayed as the decimal point when formatting a number. + * @method static string getDefaultTimeZone() Returns the time zone that is assumed for input values if they do not include a time zone explicitly. + * @method static string getLocale() Returns the locale ID that is used to localize the date and number formatting. + * @method static string getNullDisplay() Returns the text to be displayed when formatting a `null` value. + * @method static array getNumberFormatterOptions() Returns a list of name value pairs that are passed to the intl [Numberformatter::setAttribute()](http://php.net/manual/en/numberformatter.setattribute.php) method of all the number formatter objects created by [[createNumberFormatter()]]. + * @method static array getNumberFormatterSymbols() Returns a list of name value pairs that are passed to the intl [Numberformatter::setSymbol()](http://php.net/manual/en/numberformatter.setsymbol.php) method of all the number formatter objects created by [[createNumberFormatter()]]. + * @method static array getNumberFormatterTextOptions() Returns a list of name value pairs that are passed to the intl [Numberformatter::setTextAttribute()](http://php.net/manual/en/numberformatter.settextattribute.php) method of all the number formatter objects created by [[createNumberFormatter()]]. + * @method static int getSizeFormatBase() Returns the base at which a kilobyte is calculated (1000 or 1024 bytes per kilobyte), used by [[asSize]] and [[asShortSize]]. + * @method static string getThousandSeparator() Returns the character displayed as the thousands separator (also called grouping separator) character when formatting a number. + * @method static string getTimeFormat() Returns the default format string to be used to format a [[asTime()|time]]. + * @method static string getTimeZone() Returns the time zone to use for formatting time and date values. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. * @method static on(string $name, callable $handler, mixed $data = null, bool $append = true) Attaches an event handler to an event. - * @method static setBooleanFormat(array $value) Sets $booleanFormat - the text to be displayed when formatting a boolean value. - * @method static setCalendar(\IntlCalendar|int|null $value) Sets $calendar - the calendar to be used for date formatting. - * @method static setCurrencyCode(string $value) Sets $currencyCode - the 3-letter ISO 4217 currency code indicating the default currency to use for [[asCurrency]]. - * @method static setDateFormat(string $value) Sets $dateFormat - the default format string to be used to format a [[asDate()|date]]. - * @method static setDatetimeFormat(string $value) Sets $datetimeFormat - the default format string to be used to format a [[asDatetime()|date and time]]. - * @method static setDecimalSeparator(string $value) Sets $decimalSeparator - the character displayed as the decimal point when formatting a number. - * @method static setDefaultTimeZone(string $value) Sets $defaultTimeZone - the time zone that is assumed for input values if they do not include a time zone explicitly. - * @method static setLocale(string $value) Sets $locale - the locale ID that is used to localize the date and number formatting. - * @method static setNullDisplay(string $value) Sets $nullDisplay - the text to be displayed when formatting a `null` value. - * @method static setNumberFormatterOptions(array $value) Sets $numberFormatterOptions - a list of name value pairs that are passed to the intl [Numberformatter::setAttribute()](http://php.net/manual/en/numberformatter.setattribute.php) method of all the number formatter objects created by [[createNumberFormatter()]]. - * @method static setNumberFormatterSymbols(array $value) Sets $numberFormatterSymbols - a list of name value pairs that are passed to the intl [Numberformatter::setSymbol()](http://php.net/manual/en/numberformatter.setsymbol.php) method of all the number formatter objects created by [[createNumberFormatter()]]. - * @method static setNumberFormatterTextOptions(array $value) Sets $numberFormatterTextOptions - a list of name value pairs that are passed to the intl [Numberformatter::setTextAttribute()](http://php.net/manual/en/numberformatter.settextattribute.php) method of all the number formatter objects created by [[createNumberFormatter()]]. - * @method static setSizeFormatBase(int $value) Sets $sizeFormatBase - the base at which a kilobyte is calculated (1000 or 1024 bytes per kilobyte), used by [[asSize]] and [[asShortSize]]. - * @method static setThousandSeparator(string $value) Sets $thousandSeparator - the character displayed as the thousands separator (also called grouping separator) character when formatting a number. - * @method static setTimeFormat(string $value) Sets $timeFormat - the default format string to be used to format a [[asTime()|time]]. - * @method static setTimeZone(string $value) Sets $timeZone - the time zone to use for formatting time and date values. + * @method static setBooleanFormat(array $value) Sets the text to be displayed when formatting a boolean value. + * @method static setCalendar(\IntlCalendar|int|null $value) Sets the calendar to be used for date formatting. + * @method static setCurrencyCode(string $value) Sets the 3-letter ISO 4217 currency code indicating the default currency to use for [[asCurrency]]. + * @method static setDateFormat(string $value) Sets the default format string to be used to format a [[asDate()|date]]. + * @method static setDatetimeFormat(string $value) Sets the default format string to be used to format a [[asDatetime()|date and time]]. + * @method static setDecimalSeparator(string $value) Sets the character displayed as the decimal point when formatting a number. + * @method static setDefaultTimeZone(string $value) Sets the time zone that is assumed for input values if they do not include a time zone explicitly. + * @method static setLocale(string $value) Sets the locale ID that is used to localize the date and number formatting. + * @method static setNullDisplay(string $value) Sets the text to be displayed when formatting a `null` value. + * @method static setNumberFormatterOptions(array $value) Sets a list of name value pairs that are passed to the intl [Numberformatter::setAttribute()](http://php.net/manual/en/numberformatter.setattribute.php) method of all the number formatter objects created by [[createNumberFormatter()]]. + * @method static setNumberFormatterSymbols(array $value) Sets a list of name value pairs that are passed to the intl [Numberformatter::setSymbol()](http://php.net/manual/en/numberformatter.setsymbol.php) method of all the number formatter objects created by [[createNumberFormatter()]]. + * @method static setNumberFormatterTextOptions(array $value) Sets a list of name value pairs that are passed to the intl [Numberformatter::setTextAttribute()](http://php.net/manual/en/numberformatter.settextattribute.php) method of all the number formatter objects created by [[createNumberFormatter()]]. + * @method static setSizeFormatBase(int $value) Sets the base at which a kilobyte is calculated (1000 or 1024 bytes per kilobyte), used by [[asSize]] and [[asShortSize]]. + * @method static setThousandSeparator(string $value) Sets the character displayed as the thousands separator (also called grouping separator) character when formatting a number. + * @method static setTimeFormat(string $value) Sets the default format string to be used to format a [[asTime()|time]]. + * @method static setTimeZone(string $value) Sets the time zone to use for formatting time and date values. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. */ class Formatter extends Facade diff --git a/Http.php b/Http.php index 8a22207..3d61ade 100644 --- a/Http.php +++ b/Http.php @@ -1,4 +1,11 @@ get('httpClient') component. * - * @method static afterSend(\yii\httpclient\Request $request, \yii\httpclient\Response $response) This method is invoked right after request is sent. + * @see \yii\httpclient\Client * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. * @method static \yii\httpclient\Response[] batchSend(\yii\httpclient\Request[] $requests) Performs multiple HTTP requests in parallel. - * @method static beforeSend(\yii\httpclient\Request $request) This method is invoked right before request is sent. * @method static array behaviors() Returns a list of behaviors that this component should behave as. * @method static \yii\httpclient\Request createRequest() * @method static string createRequestLogToken(string $method, string $url, array $headers, string $content) Composes the log/profiling message token for the given HTTP request parameters. @@ -22,17 +28,17 @@ * @method static detachBehaviors() Detaches all behaviors from the component. * @method static ensureBehaviors() Makes sure that the behaviors declared in [[behaviors()]] are attached to this component. * @method static \yii\httpclient\Request get(string $url, array|string $data = null, array $headers = [], array $options = []) Creates 'GET' request. + * @method static string getBaseUrl() Returns base request URL. * @method static null|\yii\base\Behavior getBehavior(string $name) Returns the named behavior object. * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. + * @method static int getContentLoggingMaxSize() Returns maximum symbols count of the request content, which should be taken to compose a log and profile messages. * @method static \yii\httpclient\FormatterInterface getFormatter(string $format) Returns HTTP message formatter instance for the specified format. + * @method static array getFormatters() Returns the formatters for converting data into the content of the specified [[format]]. * @method static \yii\httpclient\ParserInterface getParser(string $format) Returns HTTP message parser instance for the specified format. + * @method static array getParsers() Returns the parsers for converting content of the specified [[format]] into the data. + * @method static array getRequestConfig() Returns request object configuration. + * @method static array getResponseConfig() Returns response config configuration. * @method static \yii\httpclient\Transport getTransport() - * @method static string getBaseUrl() Returns $baseUrl - base request URL. - * @method static int getContentLoggingMaxSize() Returns $contentLoggingMaxSize - maximum symbols count of the request content, which should be taken to compose a log and profile messages. - * @method static array getFormatters() Returns $formatters - the formatters for converting data into the content of the specified [[format]]. - * @method static array getParsers() Returns $parsers - the parsers for converting content of the specified [[format]] into the data. - * @method static array getRequestConfig() Returns $requestConfig - request object configuration. - * @method static array getResponseConfig() Returns $responseConfig - response config configuration. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static \yii\httpclient\Request head(string $url, array $headers = [], array $options = []) Creates 'HEAD' request. * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. @@ -42,13 +48,13 @@ * @method static \yii\httpclient\Request post(string $url, array|string $data = null, array $headers = [], array $options = []) Creates 'POST' request. * @method static \yii\httpclient\Request put(string $url, array|string $data = null, array $headers = [], array $options = []) Creates 'PUT' request. * @method static \yii\httpclient\Response send(\yii\httpclient\Request $request) Performs given request. + * @method static setBaseUrl(string $value) Sets base request URL. + * @method static setContentLoggingMaxSize(int $value) Sets maximum symbols count of the request content, which should be taken to compose a log and profile messages. + * @method static setFormatters(array $value) Sets the formatters for converting data into the content of the specified [[format]]. + * @method static setParsers(array $value) Sets the parsers for converting content of the specified [[format]] into the data. + * @method static setRequestConfig(array $value) Sets request object configuration. + * @method static setResponseConfig(array $value) Sets response config configuration. * @method static setTransport(\yii\httpclient\Transport|array|string $transport) Sets the HTTP message transport. - * @method static setBaseUrl(string $value) Sets $baseUrl - base request URL. - * @method static setContentLoggingMaxSize(int $value) Sets $contentLoggingMaxSize - maximum symbols count of the request content, which should be taken to compose a log and profile messages. - * @method static setFormatters(array $value) Sets $formatters - the formatters for converting data into the content of the specified [[format]]. - * @method static setParsers(array $value) Sets $parsers - the parsers for converting content of the specified [[format]] into the data. - * @method static setRequestConfig(array $value) Sets $requestConfig - request object configuration. - * @method static setResponseConfig(array $value) Sets $responseConfig - response config configuration. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. */ class Http extends Facade diff --git a/I18n.php b/I18n.php index 20d37d1..46182ea 100644 --- a/I18n.php +++ b/I18n.php @@ -1,4 +1,11 @@ get('i18n') component. * + * @see \yii\i18n\I18N * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. * @method static array behaviors() Returns a list of behaviors that this component should behave as. @@ -19,12 +27,12 @@ * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. * @method static \yii\i18n\MessageFormatter getMessageFormatter() Returns the message formatter instance. * @method static \yii\i18n\MessageSource getMessageSource(string $category) Returns the message source for the given category. - * @method static array getTranslations() Returns $translations - list of [[MessageSource]] configurations or objects. + * @method static array getTranslations() Returns list of [[MessageSource]] configurations or objects. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. * @method static on(string $name, callable $handler, mixed $data = null, bool $append = true) Attaches an event handler to an event. * @method static setMessageFormatter(string|array|\yii\i18n\MessageFormatter $value) - * @method static setTranslations(array $value) Sets $translations - list of [[MessageSource]] configurations or objects. + * @method static setTranslations(array $value) Sets list of [[MessageSource]] configurations or objects. * @method static string translate(string $category, string $message, array $params, string $language) Translates a message to the specified language. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. */ diff --git a/Log.php b/Log.php index 84e4727..82631cd 100644 --- a/Log.php +++ b/Log.php @@ -1,4 +1,11 @@ get('log') component. * + * @see \yii\log\Dispatcher * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. * @method static array behaviors() Returns a list of behaviors that this component should behave as. @@ -19,15 +27,15 @@ * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. * @method static int getFlushInterval() * @method static \yii\log\Logger getLogger() Gets the connected logger. + * @method static array|\yii\log\Target[] getTargets() Returns the log targets. * @method static int getTraceLevel() - * @method static array|\yii\log\Target[] getTargets() Returns $targets - the log targets. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. * @method static on(string $name, callable $handler, mixed $data = null, bool $append = true) Attaches an event handler to an event. * @method static setFlushInterval(int $value) * @method static setLogger(\yii\log\Logger|string|array $value) Sets the connected logger. + * @method static setTargets(array|\yii\log\Target[] $value) Sets the log targets. * @method static setTraceLevel(int $value) - * @method static setTargets(array|\yii\log\Target[] $value) Sets $targets - the log targets. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. */ class Log extends Facade diff --git a/Mailer.php b/Mailer.php index 24e15c5..f805efc 100644 --- a/Mailer.php +++ b/Mailer.php @@ -1,4 +1,11 @@ get('mailer') component. * - * @method static afterSend(\yii\mail\MessageInterface $message, bool $isSuccessful) This method is invoked right after mail was send. + * @see \yii\swiftmailer\Mailer * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. - * @method static bool beforeSend(\yii\mail\MessageInterface $message) This method is invoked right before mail send. * @method static array behaviors() Returns a list of behaviors that this component should behave as. * @method static \yii\mail\MessageInterface compose(string|array|null $view = null, array $params = []) Creates a new message instance and optionally composes its body content via view rendering. * @method static null|\yii\base\Behavior detachBehavior(string $name) Detaches a behavior from the component. @@ -20,35 +26,35 @@ * @method static string generateMessageFileName() * @method static null|\yii\base\Behavior getBehavior(string $name) Returns the named behavior object. * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. + * @method static bool getEnableSwiftMailerLogging() Returns whether to enable writing of the SwiftMailer internal logs using Yii log mechanism. + * @method static callable getFileTransportCallback() Returns a PHP callback that will be called by [[send()]] when [[useFileTransport]] is true. + * @method static string getFileTransportPath() Returns the directory where the email messages are saved when [[useFileTransport]] is true. + * @method static string|bool getHtmlLayout() Returns HTML layout view name. + * @method static string getMessageClass() Returns message default class name. + * @method static array getMessageConfig() Returns the configuration that should be applied to any newly created email message instance by [[createMessage()]] or [[compose()]]. * @method static array|\Swift_Mailer getSwiftMailer() + * @method static string|bool getTextLayout() Returns text layout view name. * @method static array|\Swift_Transport getTransport() + * @method static bool getUseFileTransport() Returns whether to save email messages as files under [[fileTransportPath]] instead of sending them to the actual recipients. * @method static \yii\web\View getView() * @method static string getViewPath() - * @method static bool getEnableSwiftMailerLogging() Returns $enableSwiftMailerLogging - whether to enable writing of the SwiftMailer internal logs using Yii log mechanism. - * @method static callable getFileTransportCallback() Returns $fileTransportCallback - a PHP callback that will be called by [[send()]] when [[useFileTransport]] is true. - * @method static string getFileTransportPath() Returns $fileTransportPath - the directory where the email messages are saved when [[useFileTransport]] is true. - * @method static string|bool getHtmlLayout() Returns $htmlLayout - HTML layout view name. - * @method static string getMessageClass() Returns $messageClass - message default class name. - * @method static array getMessageConfig() Returns $messageConfig - the configuration that should be applied to any newly created email message instance by [[createMessage()]] or [[compose()]]. - * @method static string|bool getTextLayout() Returns $textLayout - text layout view name. - * @method static bool getUseFileTransport() Returns $useFileTransport - whether to save email messages as files under [[fileTransportPath]] instead of sending them to the actual recipients. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. * @method static on(string $name, callable $handler, mixed $data = null, bool $append = true) Attaches an event handler to an event. * @method static string render(string $view, array $params = [], string|bool $layout = false) Renders the specified view with optional parameters and layout. * @method static bool send(\yii\mail\MessageInterface $message) Sends the given email message. * @method static int sendMultiple(array $messages) Sends multiple messages at once. + * @method static setEnableSwiftMailerLogging(bool $value) Sets whether to enable writing of the SwiftMailer internal logs using Yii log mechanism. + * @method static setFileTransportCallback(callable $value) Sets a PHP callback that will be called by [[send()]] when [[useFileTransport]] is true. + * @method static setFileTransportPath(string $value) Sets the directory where the email messages are saved when [[useFileTransport]] is true. + * @method static setHtmlLayout(string|bool $value) Sets HTML layout view name. + * @method static setMessageClass(string $value) Sets message default class name. + * @method static setMessageConfig(array $value) Sets the configuration that should be applied to any newly created email message instance by [[createMessage()]] or [[compose()]]. + * @method static setTextLayout(string|bool $value) Sets text layout view name. * @method static setTransport(array|\Swift_Transport $transport) + * @method static setUseFileTransport(bool $value) Sets whether to save email messages as files under [[fileTransportPath]] instead of sending them to the actual recipients. * @method static setView(array|\yii\web\View $view) * @method static setViewPath(string $path) - * @method static setEnableSwiftMailerLogging(bool $value) Sets $enableSwiftMailerLogging - whether to enable writing of the SwiftMailer internal logs using Yii log mechanism. - * @method static setFileTransportCallback(callable $value) Sets $fileTransportCallback - a PHP callback that will be called by [[send()]] when [[useFileTransport]] is true. - * @method static setFileTransportPath(string $value) Sets $fileTransportPath - the directory where the email messages are saved when [[useFileTransport]] is true. - * @method static setHtmlLayout(string|bool $value) Sets $htmlLayout - HTML layout view name. - * @method static setMessageClass(string $value) Sets $messageClass - message default class name. - * @method static setMessageConfig(array $value) Sets $messageConfig - the configuration that should be applied to any newly created email message instance by [[createMessage()]] or [[compose()]]. - * @method static setTextLayout(string|bool $value) Sets $textLayout - text layout view name. - * @method static setUseFileTransport(bool $value) Sets $useFileTransport - whether to save email messages as files under [[fileTransportPath]] instead of sending them to the actual recipients. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. */ class Mailer extends Facade diff --git a/README.md b/README.md index 217d77e..d526aba 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Laravel like facades support for Yii 2 application components. Just what you wan ## Installation -The preferred way to install this extension is through [composer](http://getcomposer.org/download/). +The preferred way to install this extension is through [composer](https://getcomposer.org/download/). Either run @@ -45,13 +45,13 @@ $random = Security::generateRandomString(128); Before: ```php -$users = Yii::$app->db->createCommand('select * from users;')->queryAll(); +$users = Yii::$app->db->createCommand('SELECT * FROM users;')->queryAll(); ``` After: ```php -$users = Db::createCommand('select * from users;')->queryAll(); +$users = Db::createCommand('SELECT * FROM users;')->queryAll(); ``` ### Format currency @@ -81,6 +81,151 @@ And set: YourFacadeName::setFoo($value) ``` +## Helpers + +Some facades also contain useful helpers to make a development more quick and elegant. + +### Cache + +#### get + +```php +public static function get($key, $default = false) +``` + +Retrieves a value using the provided key and returns it or the specified default value which can also be a closure: + +```php +$options = Cache::get('options', function () { + return [ + 'option1' => false, + 'option2' => true + ]; +}); +``` + +#### getOrSet + +```php +public static function getOrSet($key, $default, $duration = 0, $dependency = null) +``` + +Retrieves a value using the provided key or the specified default value if the value is not cached. If the value is not in the cache, it will be cached. The default value can also be a closure: + +```php +$users = Cache::getOrSet('users', function () { + return app\models\Users::findAll(); +}, 3600); +``` + +### Response + +#### bare + +```php +public static function bare($statusCode = 204, array $headers = []) +``` + +Returns an empty response with optional headers: + +```php +public function actionCreate() +{ + // ... + return Response::bare(201); +} +``` + +#### html + +```php +public static function html($data, array $headers = []) +``` + +Returns a HTML response with optional headers: + +```php +public function actionIndex() +{ + // ... + return Response::html($this->render('index'), [ + 'Cache-Control' => 'no-cache' + ]); +} +``` + +#### json + +```php +public static function json($data, array $headers = []) +``` + +Returns a JSON response with optional headers: + +```php +public function actionList() +{ + // ... + return Response::json(Db::createCommand('SELECT * FROM users')->all()); +} +``` + +#### jsonp + +```php +public static function jsonp($data, $callback = 'callback', array $headers = []) +``` + +Returns a JSONP response with optional headers: + +```php +public function actionApi($callback) +{ + // ... + return Response::jsonp([ + 'success' => true, + 'response' => $data + ], $callback); +} +``` + +#### raw + +```php +public static function raw($data, array $headers = []) +``` + +Returns a response with data "as is" with optional headers: + +```php +public function actionCreate() +{ + // ... + return Response::raw($binary, [ + 'Content-Type' => 'application/octet-stream' + ]); +} +``` + +#### xml + +```php +public static function xml($data, array $headers = []) +``` + +Returns a XML response with optional headers: + +```php +public function actionCreate() +{ + // ... + return Response::xml([ + 'success' => true, + 'response' => $data + ]); +} +``` + ## Extending If you want a new facade, it's fast and easy, imagine you want to bring a `YourFacadeName` facade: diff --git a/Redis.php b/Redis.php index 6b502fa..38b8d76 100644 --- a/Redis.php +++ b/Redis.php @@ -1,4 +1,11 @@ get('redis') component. * + * @see \yii\redis\Connection * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. * @method static array behaviors() Returns a list of behaviors that this component should behave as. @@ -18,31 +26,31 @@ * @method static array|bool|null|string executeCommand(string $name, array $params = []) Executes a redis command. * @method static null|\yii\base\Behavior getBehavior(string $name) Returns the named behavior object. * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. + * @method static float getConnectionTimeout() Returns timeout to use for connection to redis. + * @method static float getDataTimeout() Returns timeout to use for redis socket when reading and writing data. + * @method static int getDatabase() Returns the redis database to use. * @method static string getDriverName() Returns the name of the DB driver for the current [[dsn]]. + * @method static string getHostname() Returns the hostname or ip address to use for connecting to the redis server. * @method static bool getIsActive() Returns a value indicating whether the DB connection is established. * @method static \yii\redis\LuaScriptBuilder getLuaScriptBuilder() - * @method static float getConnectionTimeout() Returns $connectionTimeout - timeout to use for connection to redis. - * @method static float getDataTimeout() Returns $dataTimeout - timeout to use for redis socket when reading and writing data. - * @method static int getDatabase() Returns $database - the redis database to use. - * @method static string getHostname() Returns $hostname - the hostname or ip address to use for connecting to the redis server. - * @method static string getPassword() Returns $password - the password for establishing DB connection. - * @method static int getPort() Returns $port - the port to use for connecting to the redis server. - * @method static array getRedisCommands() Returns $redisCommands - List of available redis commands http://redis.io/commands. - * @method static int getSocketClientFlags() Returns $socketClientFlags - Bitmask field which may be set to any combination of connection flags passed to [stream_socket_client()](http://php.net/manual/en/function.stream-socket-client.php). - * @method static string getUnixSocket() Returns $unixSocket - the unix socket path (e.g. `/var/run/redis/redis.sock`) to use for connecting to the redis server. + * @method static string getPassword() Returns the password for establishing DB connection. + * @method static int getPort() Returns the port to use for connecting to the redis server. + * @method static array getRedisCommands() Returns List of available redis commands http://redis.io/commands. + * @method static int getSocketClientFlags() Returns Bitmask field which may be set to any combination of connection flags passed to [stream_socket_client()](http://php.net/manual/en/function.stream-socket-client.php). + * @method static string getUnixSocket() Returns the unix socket path (e.g. `/var/run/redis/redis.sock`) to use for connecting to the redis server. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. * @method static on(string $name, callable $handler, mixed $data = null, bool $append = true) Attaches an event handler to an event. * @method static open() Establishes a DB connection. - * @method static setConnectionTimeout(float $value) Sets $connectionTimeout - timeout to use for connection to redis. - * @method static setDataTimeout(float $value) Sets $dataTimeout - timeout to use for redis socket when reading and writing data. - * @method static setDatabase(int $value) Sets $database - the redis database to use. - * @method static setHostname(string $value) Sets $hostname - the hostname or ip address to use for connecting to the redis server. - * @method static setPassword(string $value) Sets $password - the password for establishing DB connection. - * @method static setPort(int $value) Sets $port - the port to use for connecting to the redis server. - * @method static setRedisCommands(array $value) Sets $redisCommands - List of available redis commands http://redis.io/commands. - * @method static setSocketClientFlags(int $value) Sets $socketClientFlags - Bitmask field which may be set to any combination of connection flags passed to [stream_socket_client()](http://php.net/manual/en/function.stream-socket-client.php). - * @method static setUnixSocket(string $value) Sets $unixSocket - the unix socket path (e.g. `/var/run/redis/redis.sock`) to use for connecting to the redis server. + * @method static setConnectionTimeout(float $value) Sets timeout to use for connection to redis. + * @method static setDataTimeout(float $value) Sets timeout to use for redis socket when reading and writing data. + * @method static setDatabase(int $value) Sets the redis database to use. + * @method static setHostname(string $value) Sets the hostname or ip address to use for connecting to the redis server. + * @method static setPassword(string $value) Sets the password for establishing DB connection. + * @method static setPort(int $value) Sets the port to use for connecting to the redis server. + * @method static setRedisCommands(array $value) Sets List of available redis commands http://redis.io/commands. + * @method static setSocketClientFlags(int $value) Sets Bitmask field which may be set to any combination of connection flags passed to [stream_socket_client()](http://php.net/manual/en/function.stream-socket-client.php). + * @method static setUnixSocket(string $value) Sets the unix socket path (e.g. `/var/run/redis/redis.sock`) to use for connecting to the redis server. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. */ class Redis extends Facade diff --git a/Request.php b/Request.php index 6a29dcc..53546d5 100644 --- a/Request.php +++ b/Request.php @@ -1,4 +1,11 @@ get('request') component. * + * @see \yii\console\Request + * @see \yii\web\Request * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. * @method static array behaviors() Returns a list of behaviors that this component should behave as. @@ -26,10 +35,16 @@ * @method static mixed getBodyParam(string $name, mixed $defaultValue = null) Returns the named request body parameter value. * @method static array getBodyParams() Returns the request parameters given in the request body. * @method static string getContentType() Returns request content-type. + * @method static string getCookieValidationKey() Returns a secret key used for cookie validation. * @method static \yii\web\CookieCollection getCookies() Returns the cookie collection. + * @method static array getCsrfCookie() Returns the configuration for creating the CSRF [[Cookie|cookie]]. + * @method static string getCsrfParam() Returns the name of the token used to prevent CSRF. * @method static string getCsrfToken(bool $regenerate = false) Returns the token used to perform CSRF validation. * @method static string getCsrfTokenFromHeader() * @method static array getETags() Gets the Etags. + * @method static bool getEnableCookieValidation() Returns whether cookies should be validated to ensure they are not tampered. + * @method static bool getEnableCsrfCookie() Returns whether to use cookie to persist CSRF token. + * @method static bool getEnableCsrfValidation() Returns whether to enable CSRF (Cross-Site Request Forgery) validation. * @method static \yii\web\HeaderCollection getHeaders() Returns the header collection. * @method static string getHostInfo() Returns the schema and host part of the current request URL. * @method static bool getIsAjax() Returns whether this is an AJAX (XMLHttpRequest) request. @@ -45,7 +60,9 @@ * @method static bool getIsPut() Returns whether this is a PUT request. * @method static bool getIsSecureConnection() Return if the request is sent via secure channel (https). * @method static string getMethod() Returns the method of the current request (e.g. GET, POST, HEAD, PUT, PATCH, DELETE). + * @method static string getMethodParam() Returns the name of the POST parameter that is used to indicate if a request is a PUT, PATCH or DELETE request tunneled through POST. * @method static array getParams() Returns the command line arguments. + * @method static array getParsers() Returns the parsers for converting the raw HTTP request body into [[bodyParams]]. * @method static string getPathInfo() Returns the path info of the currently requested URL. * @method static int getPort() Returns the port to use for insecure requests. * @method static string getPreferredLanguage(array $languages = []) Returns the user-preferred language that should be used by this application. @@ -54,7 +71,7 @@ * @method static string getQueryString() Returns part of the request URL that is after the question mark. * @method static string getRawBody() Returns the raw HTTP request body. * @method static string|null getReferrer() Returns the URL referrer. - * @method static string getScriptFile() Returns entry script file path. + * @method static string getScriptFile() Returns the entry script file path. * @method static string getScriptUrl() Returns the relative URL of the entry script. * @method static int getSecurePort() Returns the port to use for secure requests. * @method static string getServerName() Returns the server name. @@ -63,14 +80,6 @@ * @method static string|null getUserAgent() Returns the user agent. * @method static string|null getUserHost() Returns the user host name. * @method static string|null getUserIP() Returns the user IP address. - * @method static string getCookieValidationKey() Returns $cookieValidationKey - a secret key used for cookie validation. - * @method static array getCsrfCookie() Returns $csrfCookie - the configuration for creating the CSRF [[Cookie|cookie]]. - * @method static string getCsrfParam() Returns $csrfParam - the name of the token used to prevent CSRF. - * @method static bool getEnableCookieValidation() Returns $enableCookieValidation - whether cookies should be validated to ensure they are not tampered. - * @method static bool getEnableCsrfCookie() Returns $enableCsrfCookie - whether to use cookie to persist CSRF token. - * @method static bool getEnableCsrfValidation() Returns $enableCsrfValidation - whether to enable CSRF (Cross-Site Request Forgery) validation. - * @method static string getMethodParam() Returns $methodParam - the name of the POST parameter that is used to indicate if a request is a PUT, PATCH or DELETE request tunneled through POST. - * @method static array getParsers() Returns $parsers - the parsers for converting the raw HTTP request body into [[bodyParams]]. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. * @method static on(string $name, callable $handler, mixed $data = null, bool $append = true) Attaches an event handler to an event. @@ -81,9 +90,17 @@ * @method static setAcceptableLanguages(array $value) * @method static setBaseUrl(string $value) Sets the relative URL for the application. * @method static setBodyParams(array $values) Sets the request body parameters. + * @method static setCookieValidationKey(string $value) Sets a secret key used for cookie validation. + * @method static setCsrfCookie(array $value) Sets the configuration for creating the CSRF [[Cookie|cookie]]. + * @method static setCsrfParam(string $value) Sets the name of the token used to prevent CSRF. + * @method static setEnableCookieValidation(bool $value) Sets whether cookies should be validated to ensure they are not tampered. + * @method static setEnableCsrfCookie(bool $value) Sets whether to use cookie to persist CSRF token. + * @method static setEnableCsrfValidation(bool $value) Sets whether to enable CSRF (Cross-Site Request Forgery) validation. * @method static setHostInfo(string $value) Sets the schema and host part of the application URL. * @method static setIsConsoleRequest(bool $value) Sets the value indicating whether the current request is made via command line. + * @method static setMethodParam(string $value) Sets the name of the POST parameter that is used to indicate if a request is a PUT, PATCH or DELETE request tunneled through POST. * @method static setParams(array $params) Sets the command line arguments. + * @method static setParsers(array $value) Sets the parsers for converting the raw HTTP request body into [[bodyParams]]. * @method static setPathInfo(string $value) Sets the path info of the current request. * @method static setPort(int $value) Sets the port to use for insecure requests. * @method static setQueryParams(array $values) Sets the request [[queryString]] parameters. @@ -92,14 +109,6 @@ * @method static setScriptUrl(string $value) Sets the relative URL for the application entry script. * @method static setSecurePort(int $value) Sets the port to use for secure requests. * @method static setUrl(string $value) Sets the currently requested relative URL. - * @method static setCookieValidationKey(string $value) Sets $cookieValidationKey - a secret key used for cookie validation. - * @method static setCsrfCookie(array $value) Sets $csrfCookie - the configuration for creating the CSRF [[Cookie|cookie]]. - * @method static setCsrfParam(string $value) Sets $csrfParam - the name of the token used to prevent CSRF. - * @method static setEnableCookieValidation(bool $value) Sets $enableCookieValidation - whether cookies should be validated to ensure they are not tampered. - * @method static setEnableCsrfCookie(bool $value) Sets $enableCsrfCookie - whether to use cookie to persist CSRF token. - * @method static setEnableCsrfValidation(bool $value) Sets $enableCsrfValidation - whether to enable CSRF (Cross-Site Request Forgery) validation. - * @method static setMethodParam(string $value) Sets $methodParam - the name of the POST parameter that is used to indicate if a request is a PUT, PATCH or DELETE request tunneled through POST. - * @method static setParsers(array $value) Sets $parsers - the parsers for converting the raw HTTP request body into [[bodyParams]]. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. * @method static bool validateCsrfToken(string $token = null) Performs the CSRF validation. */ diff --git a/Response.php b/Response.php index 6c49919..a447bc5 100644 --- a/Response.php +++ b/Response.php @@ -1,4 +1,11 @@ get('response') component. * + * @see \yii\console\Response + * @see \yii\web\Response * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. * @method static array behaviors() Returns a list of behaviors that this component should behave as. @@ -16,10 +25,19 @@ * @method static null|\yii\base\Behavior detachBehavior(string $name) Detaches a behavior from the component. * @method static detachBehaviors() Detaches all behaviors from the component. * @method static ensureBehaviors() Makes sure that the behaviors declared in [[behaviors()]] are attached to this component. + * @method static string getAcceptMimeType() Returns the MIME type (e.g. `application/json`) from the request ACCEPT header chosen for this response. + * @method static array getAcceptParams() Returns the parameters (e.g. `['q' => 1, 'version' => '1.0']`) associated with the [[acceptMimeType|chosen MIME type]]. * @method static null|\yii\base\Behavior getBehavior(string $name) Returns the named behavior object. * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. + * @method static string getCharset() Returns the charset of the text response. + * @method static string getContent() Returns the response content. * @method static \yii\web\CookieCollection getCookies() Returns the cookie collection. + * @method static mixed getData() Returns the original response data. + * @method static int getExitStatus() Returns the exit status. + * @method static string getFormat() Returns the response format. + * @method static array getFormatters() Returns the formatters for converting data into the response content of the specified [[format]]. * @method static \yii\web\HeaderCollection getHeaders() Returns the header collection. + * @method static array getHttpStatuses() Returns list of HTTP status codes and the corresponding texts. * @method static bool getIsClientError() * @method static bool getIsEmpty() * @method static bool getIsForbidden() @@ -28,46 +46,37 @@ * @method static bool getIsNotFound() * @method static bool getIsOk() * @method static bool getIsRedirection() + * @method static bool getIsSent() Returns whether the response has been sent. * @method static bool getIsServerError() * @method static bool getIsSuccessful() * @method static int getStatusCode() - * @method static string getAcceptMimeType() Returns $acceptMimeType - the MIME type (e.g. `application/json`) from the request ACCEPT header chosen for this response. - * @method static array getAcceptParams() Returns $acceptParams - the parameters (e.g. `['q' => 1, 'version' => '1.0']`) associated with the [[acceptMimeType|chosen MIME type]]. - * @method static string getCharset() Returns $charset - the charset of the text response. - * @method static string getContent() Returns $content - the response content. - * @method static mixed getData() Returns $data - the original response data. - * @method static int getExitStatus() Returns $exitStatus - the exit status. - * @method static string getFormat() Returns $format - the response format. - * @method static array getFormatters() Returns $formatters - the formatters for converting data into the response content of the specified [[format]]. - * @method static array getHttpStatuses() Returns $httpStatuses - list of HTTP status codes and the corresponding texts. - * @method static bool getIsSent() Returns $isSent - whether the response has been sent. - * @method static string getStatusText() Returns $statusText - the HTTP status description that comes together with the status code. - * @method static resource|array getStream() Returns $stream - the stream to be sent. - * @method static string getVersion() Returns $version - the version of the HTTP protocol to use. + * @method static string getStatusText() Returns the HTTP status description that comes together with the status code. + * @method static resource|array getStream() Returns the stream to be sent. + * @method static string getVersion() Returns the version of the HTTP protocol to use. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. * @method static on(string $name, callable $handler, mixed $data = null, bool $append = true) Attaches an event handler to an event. * @method static \yii\web\Response redirect(string|array $url, int $statusCode = 302, bool $checkAjax = true) Redirects the browser to the specified URL. * @method static \yii\web\Response refresh(string $anchor = '') Refreshes the current page. - * @method static send() Sends the response to client. + * @method static send() Sends the response to the client. * @method static \yii\web\Response sendContentAsFile(string $content, string $attachmentName, array $options = []) Sends the specified content as a file to the browser. * @method static \yii\web\Response sendFile(string $filePath, string $attachmentName = null, array $options = []) Sends a file to the browser. * @method static \yii\web\Response sendStreamAsFile(resource $handle, string $attachmentName, array $options = []) Sends the specified stream as a file to the browser. + * @method static setAcceptMimeType(string $value) Sets the MIME type (e.g. `application/json`) from the request ACCEPT header chosen for this response. + * @method static setAcceptParams(array $value) Sets the parameters (e.g. `['q' => 1, 'version' => '1.0']`) associated with the [[acceptMimeType|chosen MIME type]]. + * @method static setCharset(string $value) Sets the charset of the text response. + * @method static setContent(string $value) Sets the response content. + * @method static setData(mixed $value) Sets the original response data. * @method static \yii\web\Response setDownloadHeaders(string $attachmentName, string $mimeType = null, bool $inline = false, int $contentLength = null) Sets a default set of HTTP headers for file downloading purpose. + * @method static setExitStatus(int $value) Sets the exit status. + * @method static setFormat(string $value) Sets the response format. + * @method static setFormatters(array $value) Sets the formatters for converting data into the response content of the specified [[format]]. + * @method static setHttpStatuses(array $value) Sets list of HTTP status codes and the corresponding texts. + * @method static setIsSent(bool $value) Sets whether the response has been sent. * @method static setStatusCode(int $value, string $text = null) Sets the response status code. - * @method static setAcceptMimeType(string $value) Sets $acceptMimeType - the MIME type (e.g. `application/json`) from the request ACCEPT header chosen for this response. - * @method static setAcceptParams(array $value) Sets $acceptParams - the parameters (e.g. `['q' => 1, 'version' => '1.0']`) associated with the [[acceptMimeType|chosen MIME type]]. - * @method static setCharset(string $value) Sets $charset - the charset of the text response. - * @method static setContent(string $value) Sets $content - the response content. - * @method static setData(mixed $value) Sets $data - the original response data. - * @method static setExitStatus(int $value) Sets $exitStatus - the exit status. - * @method static setFormat(string $value) Sets $format - the response format. - * @method static setFormatters(array $value) Sets $formatters - the formatters for converting data into the response content of the specified [[format]]. - * @method static setHttpStatuses(array $value) Sets $httpStatuses - list of HTTP status codes and the corresponding texts. - * @method static setIsSent(bool $value) Sets $isSent - whether the response has been sent. - * @method static setStatusText(string $value) Sets $statusText - the HTTP status description that comes together with the status code. - * @method static setStream(resource|array $value) Sets $stream - the stream to be sent. - * @method static setVersion(string $value) Sets $version - the version of the HTTP protocol to use. + * @method static setStatusText(string $value) Sets the HTTP status description that comes together with the status code. + * @method static setStream(resource|array $value) Sets the stream to be sent. + * @method static setVersion(string $value) Sets the version of the HTTP protocol to use. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. * @method static \yii\web\Response xSendFile(string $filePath, string $attachmentName = null, array $options = []) Sends existing file to a browser as a download using x-sendfile. */ @@ -80,4 +89,118 @@ public static function getFacadeComponentId() { return 'response'; } + + /** + * Sends an empty response. + * + * @param int $statusCode the status code + * @param array $headers headers to be sent along with the response. + * + * @return \yii\web\Response the response object itself. + */ + public static function emptyResponse($statusCode = 204, array $headers = []) + { + $response = static::sendFormat(\yii\web\Response::FORMAT_RAW, null, $headers); + $response->setStatusCode($statusCode); + return $response; + } + + /** + * Sends the specified data as HTML. + * + * @param mixed $data data to be sent. + * @param array $headers headers to be sent along with the response. + * + * @return \yii\web\Response the response object itself. + */ + public static function html($data, array $headers = []) + { + return static::sendFormat(\yii\web\Response::FORMAT_HTML, $data, $headers); + } + + /** + * Sends the specified data as JSON. + * + * @param mixed $data data to be sent. + * @param array $headers headers to be sent along with the response. + * + * @return \yii\web\Response the response object itself. + */ + public static function json($data, array $headers = []) + { + return static::sendFormat(\yii\web\Response::FORMAT_JSON, $data, $headers); + } + + /** + * Sends the specified data as JSONP. + * + * @param mixed $data data to be sent. + * @param string $callback the JSONP callback name. + * @param array $headers headers to be sent along with the response. + * + * @return \yii\web\Response the response object itself. + */ + public static function jsonp($data, $callback = 'callback', array $headers = []) + { + return static::sendFormat(\yii\web\Response::FORMAT_JSONP, [ + 'callback' => $callback, + 'data' => $data + ], $headers); + } + + /** + * Sends the specified data as is. + * + * @param mixed $data data to be sent. + * @param array $headers headers to be sent along with the response. + * + * @return \yii\web\Response the response object itself. + */ + public static function raw($data, array $headers = []) + { + return static::sendFormat(\yii\web\Response::FORMAT_RAW, $data, $headers); + } + + /** + * Sends the specified data as XML. + * + * @param mixed $data data to be sent. + * @param array $headers headers to be sent along with the response. + * + * @return \yii\web\Response the response object itself. + */ + public static function xml($data, array $headers = []) + { + return static::sendFormat(\yii\web\Response::FORMAT_XML, $data, $headers); + } + + /** + * Sends the specified data as the specified format. + * + * @param string $format the format to be set. + * @param mixed $data data to be sent. + * @param array $headers headers to be sent along with the response. + * + * @return \yii\web\Response the response object itself. + */ + protected static function sendFormat($format, $data, array $headers) + { + /** + * @var \yii\web\Response $response + */ + $response = static::getFacadeComponent(); + $response->format = $format; + $response->data = $data; + foreach ($headers as $name => $value) { + if (strtolower($name) === 'location') { + /** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */ + $value = \yii\helpers\Url::to($value); + if (strpos($value, '/') === 0 && strpos($value, '//') !== 0) { + $value = Request::getHostInfo() . $value; + } + } + $response->getHeaders()->set($name, $value); + } + return $response; + } } diff --git a/Security.php b/Security.php index 5c0df7a..6c65927 100644 --- a/Security.php +++ b/Security.php @@ -1,4 +1,11 @@ get('security') component. * + * @see \yii\base\Security * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. * @method static array behaviors() Returns a list of behaviors that this component should behave as. @@ -22,30 +30,30 @@ * @method static string generatePasswordHash(string $password, int $cost = null) Generates a secure hash from a password and a random salt. * @method static string generateRandomKey(int $length = 32) Generates specified number of random bytes. * @method static string generateRandomString(int $length = 32) Generates a random string of specified length. + * @method static array[] getAllowedCiphers() Returns Look-up table of block sizes and key sizes for each supported OpenSSL cipher. + * @method static string getAuthKeyInfo() Returns HKDF info value for derivation of message authentication key. * @method static null|\yii\base\Behavior getBehavior(string $name) Returns the named behavior object. * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. - * @method static array[] getAllowedCiphers() Returns $allowedCiphers - Look-up table of block sizes and key sizes for each supported OpenSSL cipher. - * @method static string getAuthKeyInfo() Returns $authKeyInfo - HKDF info value for derivation of message authentication key. - * @method static string getCipher() Returns $cipher - The cipher to use for encryption and decryption. - * @method static int getDerivationIterations() Returns $derivationIterations - derivation iterations count. - * @method static string getKdfHash() Returns $kdfHash - Hash algorithm for key derivation. - * @method static string getMacHash() Returns $macHash - Hash algorithm for message authentication. - * @method static int getPasswordHashCost() Returns $passwordHashCost - Default cost used for password hashing. - * @method static string getPasswordHashStrategy() Returns $passwordHashStrategy - strategy, which should be used to generate password hash. + * @method static string getCipher() Returns The cipher to use for encryption and decryption. + * @method static int getDerivationIterations() Returns derivation iterations count. + * @method static string getKdfHash() Returns Hash algorithm for key derivation. + * @method static string getMacHash() Returns Hash algorithm for message authentication. + * @method static int getPasswordHashCost() Returns Default cost used for password hashing. + * @method static string getPasswordHashStrategy() Returns strategy, which should be used to generate password hash. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static string hashData(string $data, string $key, bool $rawHash = false) Prefixes data with a keyed hash value so that it can later be detected if it is tampered. * @method static string hkdf(string $algo, string $inputKey, string $salt = null, string $info = null, int $length = 0) Derives a key from the given input key using the standard HKDF algorithm. * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. * @method static on(string $name, callable $handler, mixed $data = null, bool $append = true) Attaches an event handler to an event. * @method static string pbkdf2(string $algo, string $password, string $salt, int $iterations, int $length = 0) Derives a key from the given password using the standard PBKDF2 algorithm. - * @method static setAllowedCiphers(array[] $value) Sets $allowedCiphers - Look-up table of block sizes and key sizes for each supported OpenSSL cipher. - * @method static setAuthKeyInfo(string $value) Sets $authKeyInfo - HKDF info value for derivation of message authentication key. - * @method static setCipher(string $value) Sets $cipher - The cipher to use for encryption and decryption. - * @method static setDerivationIterations(int $value) Sets $derivationIterations - derivation iterations count. - * @method static setKdfHash(string $value) Sets $kdfHash - Hash algorithm for key derivation. - * @method static setMacHash(string $value) Sets $macHash - Hash algorithm for message authentication. - * @method static setPasswordHashCost(int $value) Sets $passwordHashCost - Default cost used for password hashing. - * @method static setPasswordHashStrategy(string $value) Sets $passwordHashStrategy - strategy, which should be used to generate password hash. + * @method static setAllowedCiphers(array[] $value) Sets Look-up table of block sizes and key sizes for each supported OpenSSL cipher. + * @method static setAuthKeyInfo(string $value) Sets HKDF info value for derivation of message authentication key. + * @method static setCipher(string $value) Sets The cipher to use for encryption and decryption. + * @method static setDerivationIterations(int $value) Sets derivation iterations count. + * @method static setKdfHash(string $value) Sets Hash algorithm for key derivation. + * @method static setMacHash(string $value) Sets Hash algorithm for message authentication. + * @method static setPasswordHashCost(int $value) Sets Default cost used for password hashing. + * @method static setPasswordHashStrategy(string $value) Sets strategy, which should be used to generate password hash. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. * @method static string validateData(string $data, string $key, bool $rawHash = false) Validates if the given data is tampered. * @method static bool validatePassword(string $password, string $hash) Verifies a password against a hash. diff --git a/Session.php b/Session.php index e3136c4..5b3be56 100644 --- a/Session.php +++ b/Session.php @@ -1,4 +1,11 @@ get('session') component. * + * @see \yii\web\Session * @method static addFlash(string $key, mixed $value = true, bool $removeAfterAccess = true) Adds a flash message. * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. @@ -28,7 +36,9 @@ * @method static array getCookieParams() * @method static int getCount() Returns the number of items in the session. * @method static mixed getFlash(string $key, mixed $defaultValue = null, bool $delete = false) Returns a flash message. + * @method static string getFlashParam() Returns the name of the session variable that stores the flash message data. * @method static float getGCProbability() + * @method static \SessionHandlerInterface|array getHandler() Returns an object implementing the SessionHandlerInterface or a configuration array. * @method static bool getHasSessionId() Returns a value indicating whether the current request has sent the session ID. * @method static string getId() Gets the session ID. * @method static bool getIsActive() @@ -38,8 +48,6 @@ * @method static bool|null getUseCookies() Returns the value indicating whether cookies should be used to store session IDs. * @method static bool getUseCustomStorage() Returns a value indicating whether to use custom session storage. * @method static bool getUseTransparentSessionID() - * @method static string getFlashParam() Returns $flashParam - the name of the session variable that stores the flash message data. - * @method static \SessionHandlerInterface|array getHandler() Returns $handler - an object implementing the SessionHandlerInterface or a configuration array. * @method static bool has(mixed $key) * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static bool hasFlash(string $key) Returns a value indicating whether there are flash messages associated with the specified key. @@ -56,7 +64,9 @@ * @method static set(string $key, mixed $value) Adds a session variable. * @method static setCookieParams(array $value) Sets the session cookie parameters. * @method static setFlash(string $key, mixed $value = true, bool $removeAfterAccess = true) Sets a flash message. + * @method static setFlashParam(string $value) Sets the name of the session variable that stores the flash message data. * @method static setGCProbability(float $value) + * @method static setHandler(\SessionHandlerInterface|array $value) Sets an object implementing the SessionHandlerInterface or a configuration array. * @method static setHasSessionId(bool $value) Sets the value indicating whether the current request has sent the session ID. * @method static setId(string $value) Sets the session ID. * @method static setName(string $value) Sets the name for the current session. @@ -64,8 +74,6 @@ * @method static setTimeout(int $value) * @method static setUseCookies(bool|null $value) Sets the value indicating whether cookies should be used to store session IDs. * @method static setUseTransparentSessionID(bool $value) - * @method static setFlashParam(string $value) Sets $flashParam - the name of the session variable that stores the flash message data. - * @method static setHandler(\SessionHandlerInterface|array $value) Sets $handler - an object implementing the SessionHandlerInterface or a configuration array. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. * @method static bool writeSession(string $id, string $data) Session write handler. */ diff --git a/Url.php b/Url.php index e0afa1a..031ec34 100644 --- a/Url.php +++ b/Url.php @@ -1,4 +1,11 @@ get('urlManager') component. * + * @see \yii\web\UrlManager * @method static addRules(array $rules, bool $append = true) Adds additional URL rules. * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. @@ -20,31 +28,31 @@ * @method static string getBaseUrl() Returns the base URL that is used by [[createUrl()]] to prepend to created URLs. * @method static null|\yii\base\Behavior getBehavior(string $name) Returns the named behavior object. * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. + * @method static \yii\caching\Cache|string getCache() Returns the cache object or the application component ID of the cache object. + * @method static bool getEnablePrettyUrl() Returns whether to enable pretty URLs. + * @method static bool getEnableStrictParsing() Returns whether to enable strict parsing. * @method static string getHostInfo() Returns the host info that is used by [[createAbsoluteUrl()]] to prepend to created URLs. + * @method static string getRouteParam() Returns the GET parameter name for route. + * @method static array getRuleConfig() Returns the default configuration of URL rules. + * @method static array getRules() Returns the rules for creating and parsing URLs when [[enablePrettyUrl]] is true. * @method static string getScriptUrl() Returns the entry script URL that is used by [[createUrl()]] to prepend to created URLs. - * @method static \yii\caching\Cache|string getCache() Returns $cache - the cache object or the application component ID of the cache object. - * @method static bool getEnablePrettyUrl() Returns $enablePrettyUrl - whether to enable pretty URLs. - * @method static bool getEnableStrictParsing() Returns $enableStrictParsing - whether to enable strict parsing. - * @method static string getRouteParam() Returns $routeParam - the GET parameter name for route. - * @method static array getRuleConfig() Returns $ruleConfig - the default configuration of URL rules. - * @method static array getRules() Returns $rules - the rules for creating and parsing URLs when [[enablePrettyUrl]] is true. - * @method static bool getShowScriptName() Returns $showScriptName - whether to show entry script name in the constructed URL. - * @method static string getSuffix() Returns $suffix - the URL suffix used when in 'path' format. + * @method static bool getShowScriptName() Returns whether to show entry script name in the constructed URL. + * @method static string getSuffix() Returns the URL suffix used when in 'path' format. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. * @method static on(string $name, callable $handler, mixed $data = null, bool $append = true) Attaches an event handler to an event. * @method static array|bool parseRequest(\yii\web\Request $request) Parses the user request. * @method static setBaseUrl(string $value) Sets the base URL that is used by [[createUrl()]] to prepend to created URLs. + * @method static setCache(\yii\caching\Cache|string $value) Sets the cache object or the application component ID of the cache object. + * @method static setEnablePrettyUrl(bool $value) Sets whether to enable pretty URLs. + * @method static setEnableStrictParsing(bool $value) Sets whether to enable strict parsing. * @method static setHostInfo(string $value) Sets the host info that is used by [[createAbsoluteUrl()]] to prepend to created URLs. + * @method static setRouteParam(string $value) Sets the GET parameter name for route. + * @method static setRuleConfig(array $value) Sets the default configuration of URL rules. + * @method static setRules(array $value) Sets the rules for creating and parsing URLs when [[enablePrettyUrl]] is true. * @method static setScriptUrl(string $value) Sets the entry script URL that is used by [[createUrl()]] to prepend to created URLs. - * @method static setCache(\yii\caching\Cache|string $value) Sets $cache - the cache object or the application component ID of the cache object. - * @method static setEnablePrettyUrl(bool $value) Sets $enablePrettyUrl - whether to enable pretty URLs. - * @method static setEnableStrictParsing(bool $value) Sets $enableStrictParsing - whether to enable strict parsing. - * @method static setRouteParam(string $value) Sets $routeParam - the GET parameter name for route. - * @method static setRuleConfig(array $value) Sets $ruleConfig - the default configuration of URL rules. - * @method static setRules(array $value) Sets $rules - the rules for creating and parsing URLs when [[enablePrettyUrl]] is true. - * @method static setShowScriptName(bool $value) Sets $showScriptName - whether to show entry script name in the constructed URL. - * @method static setSuffix(string $value) Sets $suffix - the URL suffix used when in 'path' format. + * @method static setShowScriptName(bool $value) Sets whether to show entry script name in the constructed URL. + * @method static setSuffix(string $value) Sets the URL suffix used when in 'path' format. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. */ class Url extends Facade diff --git a/User.php b/User.php index 6cca9a4..1c40bf4 100644 --- a/User.php +++ b/User.php @@ -1,4 +1,11 @@ get('user') component. * + * @see \yii\web\User * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. * @method static array behaviors() Returns a list of behaviors that this component should behave as. @@ -15,26 +23,26 @@ * @method static null|\yii\base\Behavior detachBehavior(string $name) Detaches a behavior from the component. * @method static detachBehaviors() Detaches all behaviors from the component. * @method static ensureBehaviors() Makes sure that the behaviors declared in [[behaviors()]] are attached to this component. + * @method static int getAbsoluteAuthTimeout() Returns the number of seconds in which the user will be logged out automatically regardless of activity. + * @method static string getAbsoluteAuthTimeoutParam() Returns the session variable name used to store the value of absolute expiration timestamp of the authenticated state. + * @method static array getAcceptableRedirectTypes() Returns MIME types for which this component should redirect to the [[loginUrl]]. + * @method static \yii\rbac\CheckAccessInterface getAccessChecker() Returns The acess checker to use for checking access. + * @method static int getAuthTimeout() Returns the number of seconds in which the user will be logged out automatically if he remains inactive. + * @method static string getAuthTimeoutParam() Returns the session variable name used to store the value of expiration timestamp of the authenticated state. + * @method static bool getAutoRenewCookie() Returns whether to automatically renew the identity cookie each time a page is requested. * @method static null|\yii\base\Behavior getBehavior(string $name) Returns the named behavior object. * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. + * @method static bool getEnableAutoLogin() Returns whether to enable cookie-based login. + * @method static bool getEnableSession() Returns whether to use session to persist authentication status across multiple requests. * @method static string|int getId() Returns a value that uniquely represents the user. + * @method static string getIdParam() Returns the session variable name used to store the value of [[id]]. * @method static \yii\web\IdentityInterface|null getIdentity(bool $autoRenew = true) Returns the identity object associated with the currently logged-in user. + * @method static string getIdentityClass() Returns the class name of the [[identity]] object. + * @method static array getIdentityCookie() Returns the configuration of the identity cookie. * @method static bool getIsGuest() Returns a value indicating whether the user is a guest (not authenticated). + * @method static string|array getLoginUrl() Returns the URL for login when [[loginRequired()]] is called. * @method static string getReturnUrl(string|array $defaultUrl = null) Returns the URL that the browser should be redirected to after successful login. - * @method static int getAbsoluteAuthTimeout() Returns $absoluteAuthTimeout - the number of seconds in which the user will be logged out automatically regardless of activity. - * @method static string getAbsoluteAuthTimeoutParam() Returns $absoluteAuthTimeoutParam - the session variable name used to store the value of absolute expiration timestamp of the authenticated state. - * @method static array getAcceptableRedirectTypes() Returns $acceptableRedirectTypes - MIME types for which this component should redirect to the [[loginUrl]]. - * @method static \yii\rbac\CheckAccessInterface getAccessChecker() Returns $accessChecker - The acess checker to use for checking access. - * @method static int getAuthTimeout() Returns $authTimeout - the number of seconds in which the user will be logged out automatically if he remains inactive. - * @method static string getAuthTimeoutParam() Returns $authTimeoutParam - the session variable name used to store the value of expiration timestamp of the authenticated state. - * @method static bool getAutoRenewCookie() Returns $autoRenewCookie - whether to automatically renew the identity cookie each time a page is requested. - * @method static bool getEnableAutoLogin() Returns $enableAutoLogin - whether to enable cookie-based login. - * @method static bool getEnableSession() Returns $enableSession - whether to use session to persist authentication status across multiple requests. - * @method static string getIdParam() Returns $idParam - the session variable name used to store the value of [[id]]. - * @method static string getIdentityClass() Returns $identityClass - the class name of the [[identity]] object. - * @method static array getIdentityCookie() Returns $identityCookie - the configuration of the identity cookie. - * @method static string|array getLoginUrl() Returns $loginUrl - the URL for login when [[loginRequired()]] is called. - * @method static string getReturnUrlParam() Returns $returnUrlParam - the session variable name used to store the value of [[returnUrl]]. + * @method static string getReturnUrlParam() Returns the session variable name used to store the value of [[returnUrl]]. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static bool login(\yii\web\IdentityInterface $identity, int $duration = 0) Logs in a user. * @method static \yii\web\IdentityInterface|null loginByAccessToken(string $token, mixed $type = null) Logs in a user by the given access token. @@ -42,22 +50,22 @@ * @method static bool logout(bool $destroySession = true) Logs out the current user. * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. * @method static on(string $name, callable $handler, mixed $data = null, bool $append = true) Attaches an event handler to an event. + * @method static setAbsoluteAuthTimeout(int $value) Sets the number of seconds in which the user will be logged out automatically regardless of activity. + * @method static setAbsoluteAuthTimeoutParam(string $value) Sets the session variable name used to store the value of absolute expiration timestamp of the authenticated state. + * @method static setAcceptableRedirectTypes(array $value) Sets MIME types for which this component should redirect to the [[loginUrl]]. + * @method static setAccessChecker(\yii\rbac\CheckAccessInterface $value) Sets The acess checker to use for checking access. + * @method static setAuthTimeout(int $value) Sets the number of seconds in which the user will be logged out automatically if he remains inactive. + * @method static setAuthTimeoutParam(string $value) Sets the session variable name used to store the value of expiration timestamp of the authenticated state. + * @method static setAutoRenewCookie(bool $value) Sets whether to automatically renew the identity cookie each time a page is requested. + * @method static setEnableAutoLogin(bool $value) Sets whether to enable cookie-based login. + * @method static setEnableSession(bool $value) Sets whether to use session to persist authentication status across multiple requests. + * @method static setIdParam(string $value) Sets the session variable name used to store the value of [[id]]. * @method static setIdentity(\yii\web\IdentityInterface|null $identity) Sets the user identity object. + * @method static setIdentityClass(string $value) Sets the class name of the [[identity]] object. + * @method static setIdentityCookie(array $value) Sets the configuration of the identity cookie. + * @method static setLoginUrl(string|array $value) Sets the URL for login when [[loginRequired()]] is called. * @method static setReturnUrl(string|array $url) Remembers the URL in the session so that it can be retrieved back later by [[getReturnUrl()]]. - * @method static setAbsoluteAuthTimeout(int $value) Sets $absoluteAuthTimeout - the number of seconds in which the user will be logged out automatically regardless of activity. - * @method static setAbsoluteAuthTimeoutParam(string $value) Sets $absoluteAuthTimeoutParam - the session variable name used to store the value of absolute expiration timestamp of the authenticated state. - * @method static setAcceptableRedirectTypes(array $value) Sets $acceptableRedirectTypes - MIME types for which this component should redirect to the [[loginUrl]]. - * @method static setAccessChecker(\yii\rbac\CheckAccessInterface $value) Sets $accessChecker - The acess checker to use for checking access. - * @method static setAuthTimeout(int $value) Sets $authTimeout - the number of seconds in which the user will be logged out automatically if he remains inactive. - * @method static setAuthTimeoutParam(string $value) Sets $authTimeoutParam - the session variable name used to store the value of expiration timestamp of the authenticated state. - * @method static setAutoRenewCookie(bool $value) Sets $autoRenewCookie - whether to automatically renew the identity cookie each time a page is requested. - * @method static setEnableAutoLogin(bool $value) Sets $enableAutoLogin - whether to enable cookie-based login. - * @method static setEnableSession(bool $value) Sets $enableSession - whether to use session to persist authentication status across multiple requests. - * @method static setIdParam(string $value) Sets $idParam - the session variable name used to store the value of [[id]]. - * @method static setIdentityClass(string $value) Sets $identityClass - the class name of the [[identity]] object. - * @method static setIdentityCookie(array $value) Sets $identityCookie - the configuration of the identity cookie. - * @method static setLoginUrl(string|array $value) Sets $loginUrl - the URL for login when [[loginRequired()]] is called. - * @method static setReturnUrlParam(string $value) Sets $returnUrlParam - the session variable name used to store the value of [[returnUrl]]. + * @method static setReturnUrlParam(string $value) Sets the session variable name used to store the value of [[returnUrl]]. * @method static switchIdentity(\yii\web\IdentityInterface|null $identity, int $duration = 0) Switches to a new identity for the current user. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. */ diff --git a/View.php b/View.php index c10e52f..6146914 100644 --- a/View.php +++ b/View.php @@ -1,4 +1,11 @@ get('view') component. * + * @see \yii\web\View * @method static addDynamicPlaceholder(string $placeholder, string $statements) Adds a placeholder for dynamic content. - * @method static afterRender(string $viewFile, array $params, string $output) This method is invoked right after [[renderFile()]] renders a view file. * @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. * @method static attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. - * @method static bool beforeRender(string $viewFile, array $params) This method is invoked right before [[renderFile()]] renders a view file. * @method static \yii\widgets\Block beginBlock(string $id, bool $renderInPlace = false) Begins recording a block. * @method static beginBody() Marks the beginning of an HTML body section. * @method static bool beginCache(string $id, array $properties = []) Begins fragment caching. @@ -29,26 +35,26 @@ * @method static endPage(bool $ajaxMode = false) Marks the ending of an HTML page. * @method static ensureBehaviors() Makes sure that the behaviors declared in [[behaviors()]] are attached to this component. * @method static mixed evaluateDynamicContent(string $statements) Evaluates the given PHP statements. + * @method static \yii\web\AssetBundle[] getAssetBundles() Returns list of the registered asset bundles. * @method static \yii\web\AssetManager getAssetManager() Registers the asset manager being used by this view object. * @method static null|\yii\base\Behavior getBehavior(string $name) Returns the named behavior object. * @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. + * @method static array getBlocks() Returns a list of named output blocks. + * @method static array getCacheStack() Returns a list of currently active fragment cache widgets. + * @method static \yii\base\ViewContextInterface getContext() Returns the context under which the [[renderFile()]] method is being invoked. + * @method static array getCss() Returns the registered CSS code blocks. + * @method static array getCssFiles() Returns the registered CSS files. + * @method static string getDefaultExtension() Returns the default view file extension. + * @method static array getDynamicPlaceholders() Returns a list of placeholders for embedding dynamic contents. + * @method static array getJs() Returns the registered JS code blocks. + * @method static array getJsFiles() Returns the registered JS files. + * @method static array getLinkTags() Returns the registered link tags. + * @method static array getMetaTags() Returns the registered meta tags. + * @method static mixed getParams() Returns custom parameters that are shared among view templates. + * @method static array getRenderers() Returns a list of available renderers indexed by their corresponding supported file extensions. + * @method static \yii\base\Theme|array|string getTheme() Returns the theme object or the configuration for creating the theme object. + * @method static string getTitle() Returns the page title. * @method static string|bool getViewFile() - * @method static \yii\web\AssetBundle[] getAssetBundles() Returns $assetBundles - list of the registered asset bundles. - * @method static array getBlocks() Returns $blocks - a list of named output blocks. - * @method static array getCacheStack() Returns $cacheStack - a list of currently active fragment cache widgets. - * @method static \yii\base\ViewContextInterface getContext() Returns $context - the context under which the [[renderFile()]] method is being invoked. - * @method static array getCss() Returns $css - the registered CSS code blocks. - * @method static array getCssFiles() Returns $cssFiles - the registered CSS files. - * @method static string getDefaultExtension() Returns $defaultExtension - the default view file extension. - * @method static array getDynamicPlaceholders() Returns $dynamicPlaceholders - a list of placeholders for embedding dynamic contents. - * @method static array getJs() Returns $js - the registered JS code blocks. - * @method static array getJsFiles() Returns $jsFiles - the registered JS files. - * @method static array getLinkTags() Returns $linkTags - the registered link tags. - * @method static array getMetaTags() Returns $metaTags - the registered meta tags. - * @method static mixed getParams() Returns $params - custom parameters that are shared among view templates. - * @method static array getRenderers() Returns $renderers - a list of available renderers indexed by their corresponding supported file extensions. - * @method static \yii\base\Theme|array|string getTheme() Returns $theme - the theme object or the configuration for creating the theme object. - * @method static string getTitle() Returns $title - the page title. * @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. * @method static head() Marks the position of an HTML head section. * @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. @@ -65,23 +71,23 @@ * @method static string renderDynamic(string $statements) Renders dynamic content returned by the given PHP statements. * @method static string renderFile(string $viewFile, array $params = [], object $context = null) Renders a view file. * @method static string renderPhpFile(string $_file_, array $_params_ = []) Renders a view file as a PHP script. + * @method static setAssetBundles(\yii\web\AssetBundle[] $value) Sets list of the registered asset bundles. * @method static setAssetManager(\yii\web\AssetManager $value) Sets the asset manager. - * @method static setAssetBundles(\yii\web\AssetBundle[] $value) Sets $assetBundles - list of the registered asset bundles. - * @method static setBlocks(array $value) Sets $blocks - a list of named output blocks. - * @method static setCacheStack(array $value) Sets $cacheStack - a list of currently active fragment cache widgets. - * @method static setContext(\yii\base\ViewContextInterface $value) Sets $context - the context under which the [[renderFile()]] method is being invoked. - * @method static setCss(array $value) Sets $css - the registered CSS code blocks. - * @method static setCssFiles(array $value) Sets $cssFiles - the registered CSS files. - * @method static setDefaultExtension(string $value) Sets $defaultExtension - the default view file extension. - * @method static setDynamicPlaceholders(array $value) Sets $dynamicPlaceholders - a list of placeholders for embedding dynamic contents. - * @method static setJs(array $value) Sets $js - the registered JS code blocks. - * @method static setJsFiles(array $value) Sets $jsFiles - the registered JS files. - * @method static setLinkTags(array $value) Sets $linkTags - the registered link tags. - * @method static setMetaTags(array $value) Sets $metaTags - the registered meta tags. - * @method static setParams(mixed $value) Sets $params - custom parameters that are shared among view templates. - * @method static setRenderers(array $value) Sets $renderers - a list of available renderers indexed by their corresponding supported file extensions. - * @method static setTheme(\yii\base\Theme|array|string $value) Sets $theme - the theme object or the configuration for creating the theme object. - * @method static setTitle(string $value) Sets $title - the page title. + * @method static setBlocks(array $value) Sets a list of named output blocks. + * @method static setCacheStack(array $value) Sets a list of currently active fragment cache widgets. + * @method static setContext(\yii\base\ViewContextInterface $value) Sets the context under which the [[renderFile()]] method is being invoked. + * @method static setCss(array $value) Sets the registered CSS code blocks. + * @method static setCssFiles(array $value) Sets the registered CSS files. + * @method static setDefaultExtension(string $value) Sets the default view file extension. + * @method static setDynamicPlaceholders(array $value) Sets a list of placeholders for embedding dynamic contents. + * @method static setJs(array $value) Sets the registered JS code blocks. + * @method static setJsFiles(array $value) Sets the registered JS files. + * @method static setLinkTags(array $value) Sets the registered link tags. + * @method static setMetaTags(array $value) Sets the registered meta tags. + * @method static setParams(mixed $value) Sets custom parameters that are shared among view templates. + * @method static setRenderers(array $value) Sets a list of available renderers indexed by their corresponding supported file extensions. + * @method static setTheme(\yii\base\Theme|array|string $value) Sets the theme object or the configuration for creating the theme object. + * @method static setTitle(string $value) Sets the page title. * @method static trigger(string $name, \yii\base\Event $event = null) Triggers an event. */ class View extends Facade diff --git a/composer.json b/composer.json index a122dd4..230fcc2 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ ], "minimum-stability": "dev", "require": { - "yiisoft/yii2": "~2.0.0" + "yiisoft/yii2": "~2.0.1" }, "autoload": { "psr-4": {