Commit 6ebcd9ac by Carsten Brandt

fixed absolute class links in guide

parent c46b35b1
...@@ -59,7 +59,7 @@ Asset bundles are regular classes so if you need to define another one, just cre ...@@ -59,7 +59,7 @@ Asset bundles are regular classes so if you need to define another one, just cre
class can be placed anywhere but the convention for it is to be under `assets` directory of the application. class can be placed anywhere but the convention for it is to be under `assets` directory of the application.
Additionally you may specify `$jsOptions`, `$cssOptions` and `$publishOptions` that will be passed to Additionally you may specify `$jsOptions`, `$cssOptions` and `$publishOptions` that will be passed to
[[\yii\web\View::registerJsFile()]], [[\yii\web\View::registerCssFile()]] and [[\yii\web\AssetManager::publish()]] [[yii\web\View::registerJsFile()]], [[yii\web\View::registerCssFile()]] and [[yii\web\AssetManager::publish()]]
respectively during registering and publising an asset. respectively during registering and publising an asset.
Registering asset bundle Registering asset bundle
......
...@@ -3,7 +3,7 @@ Authentication ...@@ -3,7 +3,7 @@ Authentication
Authentication is the act of verifying who a user is, and is the basis of the login process. Typically, authentication uses the combination of an identifier--a username or email address--and a password. The user submits these values through a form, and the application then compares the submitted information against that previously stored (e.g., upon registration). Authentication is the act of verifying who a user is, and is the basis of the login process. Typically, authentication uses the combination of an identifier--a username or email address--and a password. The user submits these values through a form, and the application then compares the submitted information against that previously stored (e.g., upon registration).
In Yii, this entire process is performed semi-automatically, leaving the developer to merely implement [[\yii\web\IdentityInterface]], the most important class in the authentication system. Typically, implementation of `IdentityInterface` is accomplished using the `User` model. In Yii, this entire process is performed semi-automatically, leaving the developer to merely implement [[yii\web\IdentityInterface]], the most important class in the authentication system. Typically, implementation of `IdentityInterface` is accomplished using the `User` model.
You can find a full featured example of authentication in the You can find a full featured example of authentication in the
[advanced application template](installation.md). Below, only the interface methods are listed: [advanced application template](installation.md). Below, only the interface methods are listed:
......
...@@ -7,7 +7,7 @@ of controlling it. ...@@ -7,7 +7,7 @@ of controlling it.
Access control basics Access control basics
--------------------- ---------------------
Basic access control is very simple to implement using [[\yii\web\AccessControl]]: Basic access control is very simple to implement using [[yii\web\AccessControl]]:
```php ```php
class SiteController extends Controller class SiteController extends Controller
...@@ -38,7 +38,7 @@ class SiteController extends Controller ...@@ -38,7 +38,7 @@ class SiteController extends Controller
In the code above we're attaching access control behavior to a controller. Since there's `only` option specified, it In the code above we're attaching access control behavior to a controller. Since there's `only` option specified, it
will be applied to 'login', 'logout' and 'signup' actions only. A set of rules that are basically options for will be applied to 'login', 'logout' and 'signup' actions only. A set of rules that are basically options for
[[\yii\web\AccessRule]] reads as follows: [[yii\web\AccessRule]] reads as follows:
- Allow all guest (not yet authenticated) users to access 'login' and 'signup' actions. - Allow all guest (not yet authenticated) users to access 'login' and 'signup' actions.
- Allow authenticated users to access 'logout' action. - Allow authenticated users to access 'logout' action.
...@@ -46,7 +46,7 @@ will be applied to 'login', 'logout' and 'signup' actions only. A set of rules t ...@@ -46,7 +46,7 @@ will be applied to 'login', 'logout' and 'signup' actions only. A set of rules t
Rules are checked one by one from top to bottom. If rule matches, action takes place immediately. If not, next rule is Rules are checked one by one from top to bottom. If rule matches, action takes place immediately. If not, next rule is
checked. If no rules matched access is denied. checked. If no rules matched access is denied.
[[\yii\web\AccessRule]] is quite flexible and allows additionally to what was demonstrated checking IPs and request method [[yii\web\AccessRule]] is quite flexible and allows additionally to what was demonstrated checking IPs and request method
(i.e. POST, GET). If it's not enough you can specify your own check via anonymous function: (i.e. POST, GET). If it's not enough you can specify your own check via anonymous function:
```php ```php
......
...@@ -38,38 +38,38 @@ When the application is running, the cache component can be accessed through `Yi ...@@ -38,38 +38,38 @@ When the application is running, the cache component can be accessed through `Yi
Yii provides various cache components that can store cached data in different media. The following Yii provides various cache components that can store cached data in different media. The following
is a summary of the available cache components: is a summary of the available cache components:
* [[\yii\caching\ApcCache]]: uses PHP [APC](http://php.net/manual/en/book.apc.php) extension. This option can be * [[yii\caching\ApcCache]]: uses PHP [APC](http://php.net/manual/en/book.apc.php) extension. This option can be
considered as the fastest one when dealing with cache for a centralized thick application (e.g. one considered as the fastest one when dealing with cache for a centralized thick application (e.g. one
server, no dedicated load balancers, etc.). server, no dedicated load balancers, etc.).
* [[\yii\caching\DbCache]]: uses a database table to store cached data. By default, it will create and use a * [[yii\caching\DbCache]]: uses a database table to store cached data. By default, it will create and use a
[SQLite3](http://sqlite.org/) database under the runtime directory. You can explicitly specify a database for [SQLite3](http://sqlite.org/) database under the runtime directory. You can explicitly specify a database for
it to use by setting its `db` property. it to use by setting its `db` property.
* [[\yii\caching\DummyCache]]: presents dummy cache that does no caching at all. The purpose of this component * [[yii\caching\DummyCache]]: presents dummy cache that does no caching at all. The purpose of this component
is to simplify the code that needs to check the availability of cache. For example, during development or if is to simplify the code that needs to check the availability of cache. For example, during development or if
the server doesn't have actual cache support, we can use this cache component. When an actual cache support the server doesn't have actual cache support, we can use this cache component. When an actual cache support
is enabled, we can switch to use the corresponding cache component. In both cases, we can use the same is enabled, we can switch to use the corresponding cache component. In both cases, we can use the same
code `Yii::$app->cache->get($key)` to attempt retrieving a piece of data without worrying that code `Yii::$app->cache->get($key)` to attempt retrieving a piece of data without worrying that
`Yii::$app->cache` might be `null`. `Yii::$app->cache` might be `null`.
* [[\yii\caching\FileCache]]: uses standard files to store cached data. This is particular suitable * [[yii\caching\FileCache]]: uses standard files to store cached data. This is particular suitable
to cache large chunk of data (such as pages). to cache large chunk of data (such as pages).
* [[\yii\caching\MemCache]]: uses PHP [memcache](http://php.net/manual/en/book.memcache.php) * [[yii\caching\MemCache]]: uses PHP [memcache](http://php.net/manual/en/book.memcache.php)
and [memcached](http://php.net/manual/en/book.memcached.php) extensions. This option can be considered as and [memcached](http://php.net/manual/en/book.memcached.php) extensions. This option can be considered as
the fastest one when dealing with cache in a distributed applications (e.g. with several servers, load the fastest one when dealing with cache in a distributed applications (e.g. with several servers, load
balancers, etc.) balancers, etc.)
* [[\yii\redis\Cache]]: implements a cache component based on [Redis](http://redis.io/) key-value store * [[yii\redis\Cache]]: implements a cache component based on [Redis](http://redis.io/) key-value store
(redis version 2.6.12 or higher is required). (redis version 2.6.12 or higher is required).
* [[\yii\caching\WinCache]]: uses PHP [WinCache](http://iis.net/downloads/microsoft/wincache-extension) * [[yii\caching\WinCache]]: uses PHP [WinCache](http://iis.net/downloads/microsoft/wincache-extension)
([see also](http://php.net/manual/en/book.wincache.php)) extension. ([see also](http://php.net/manual/en/book.wincache.php)) extension.
* [[\yii\caching\XCache]]: uses PHP [XCache](http://xcache.lighttpd.net/) extension. * [[yii\caching\XCache]]: uses PHP [XCache](http://xcache.lighttpd.net/) extension.
* [[\yii\caching\ZendDataCache]]: uses * [[yii\caching\ZendDataCache]]: uses
[Zend Data Cache](http://files.zend.com/help/Zend-Server-6/zend-server.htm#data_cache_component.htm) [Zend Data Cache](http://files.zend.com/help/Zend-Server-6/zend-server.htm#data_cache_component.htm)
as the underlying caching medium. as the underlying caching medium.
...@@ -91,7 +91,7 @@ Data Caching ...@@ -91,7 +91,7 @@ Data Caching
------------ ------------
Data caching is about storing some PHP variable in cache and retrieving it later from cache. For this purpose, Data caching is about storing some PHP variable in cache and retrieving it later from cache. For this purpose,
the cache component base class [[\yii\caching\Cache]] provides two methods that are used most of the time: the cache component base class [[yii\caching\Cache]] provides two methods that are used most of the time:
[[yii\caching\Cache::set()|set()]] and [[yii\caching\Cache::get()|get()]]. Note, only serializable variables and objects could be cached successfully. [[yii\caching\Cache::set()|set()]] and [[yii\caching\Cache::get()|get()]]. Note, only serializable variables and objects could be cached successfully.
To store a variable `$value` in cache, we choose a unique `$key` and call [[yii\caching\Cache::set()|set()]] to store it: To store a variable `$value` in cache, we choose a unique `$key` and call [[yii\caching\Cache::set()|set()]] to store it:
...@@ -158,7 +158,7 @@ Besides expiration setting, cached data may also be invalidated according to som ...@@ -158,7 +158,7 @@ Besides expiration setting, cached data may also be invalidated according to som
are caching the content of some file and the file is changed, we should invalidate the cached copy and read the latest are caching the content of some file and the file is changed, we should invalidate the cached copy and read the latest
content from the file instead of the cache. content from the file instead of the cache.
We represent a dependency as an instance of [[\yii\caching\Dependency]] or its child class. We pass the dependency We represent a dependency as an instance of [[yii\caching\Dependency]] or its child class. We pass the dependency
instance along with the data to be cached when calling [[yii\caching\Cache::set()|set()]]. instance along with the data to be cached when calling [[yii\caching\Cache::set()|set()]].
```php ```php
...@@ -174,12 +174,12 @@ get a false value, indicating the data needs to be regenerated. ...@@ -174,12 +174,12 @@ get a false value, indicating the data needs to be regenerated.
Below is a summary of the available cache dependencies: Below is a summary of the available cache dependencies:
- [[\yii\caching\FileDependency]]: the dependency is changed if the file's last modification time is changed. - [[yii\caching\FileDependency]]: the dependency is changed if the file's last modification time is changed.
- [[\yii\caching\GroupDependency]]: marks a cached data item with a group name. You may invalidate the cached data items - [[yii\caching\GroupDependency]]: marks a cached data item with a group name. You may invalidate the cached data items
with the same group name all at once by calling [[\yii\caching\GroupDependency::invalidate()]]. with the same group name all at once by calling [[yii\caching\GroupDependency::invalidate()]].
- [[\yii\caching\DbDependency]]: the dependency is changed if the query result of the specified SQL statement is changed. - [[yii\caching\DbDependency]]: the dependency is changed if the query result of the specified SQL statement is changed.
- [[\yii\caching\ChainedDependency]]: the dependency is changed if any of the dependencies on the chain is changed. - [[yii\caching\ChainedDependency]]: the dependency is changed if any of the dependencies on the chain is changed.
- [[\yii\caching\ExpressionDependency]]: the dependency is changed if the result of the specified PHP expression is - [[yii\caching\ExpressionDependency]]: the dependency is changed if the result of the specified PHP expression is
changed. changed.
### Query Caching ### Query Caching
......
...@@ -104,7 +104,7 @@ You can use them to write database independent migrations. ...@@ -104,7 +104,7 @@ You can use them to write database independent migrations.
For example `pk` will be replaced by `int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY` For example `pk` will be replaced by `int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY`
for MySQL and `integer PRIMARY KEY AUTOINCREMENT NOT NULL` for sqlite. for MySQL and `integer PRIMARY KEY AUTOINCREMENT NOT NULL` for sqlite.
See documentation of [[yii\db\QueryBuilder::getColumnType()]] for more details and a list See documentation of [[yii\db\QueryBuilder::getColumnType()]] for more details and a list
of available types. You may also use the constants defined in [[\yii\db\Schema]] to of available types. You may also use the constants defined in [[yii\db\Schema]] to
define column types. define column types.
......
...@@ -2,7 +2,7 @@ Console applications ...@@ -2,7 +2,7 @@ Console applications
==================== ====================
Yii has full featured support of console. Console application structure in Yii is very similar to web application. It Yii has full featured support of console. Console application structure in Yii is very similar to web application. It
consists of one or more [[\yii\console\Controller]] (often referred to as commands). Each has one or more actions. consists of one or more [[yii\console\Controller]] (often referred to as commands). Each has one or more actions.
Usage Usage
----- -----
......
...@@ -11,7 +11,7 @@ Basics ...@@ -11,7 +11,7 @@ Basics
Controller resides in application's `controllers` directory and is named like `SiteController.php`, Controller resides in application's `controllers` directory and is named like `SiteController.php`,
where the `Site` part could be anything describing a set of actions it contains. where the `Site` part could be anything describing a set of actions it contains.
The basic web controller is a class that extends [[\yii\web\Controller]] and could be very simple: The basic web controller is a class that extends [[yii\web\Controller]] and could be very simple:
```php ```php
namespace app\controllers; namespace app\controllers;
...@@ -97,12 +97,12 @@ In case module, controller or action specified isn't found Yii will return "not ...@@ -97,12 +97,12 @@ In case module, controller or action specified isn't found Yii will return "not
### Defaults ### Defaults
If user isn't specifying any route i.e. using URL like `http://example.com/`, Yii assumes that default route should be If user isn't specifying any route i.e. using URL like `http://example.com/`, Yii assumes that default route should be
used. It is determined by [[\yii\web\Application::defaultRoute]] method and is `site` by default meaning that `SiteController` used. It is determined by [[yii\web\Application::defaultRoute]] method and is `site` by default meaning that `SiteController`
will be loaded. will be loaded.
A controller has a default action. When the user request does not specify which action to execute by using an URL such as A controller has a default action. When the user request does not specify which action to execute by using an URL such as
`http://example.com/?r=site`, the default action will be executed. By default, the default action is named as `index`. `http://example.com/?r=site`, the default action will be executed. By default, the default action is named as `index`.
It can be changed by setting the [[\yii\base\Controller::defaultAction]] property. It can be changed by setting the [[yii\base\Controller::defaultAction]] property.
Action parameters Action parameters
----------------- -----------------
......
...@@ -53,7 +53,7 @@ After the connection component is configured you can access it using the followi ...@@ -53,7 +53,7 @@ After the connection component is configured you can access it using the followi
$connection = \Yii::$app->db; $connection = \Yii::$app->db;
``` ```
You can refer to [[\yii\db\Connection]] for a list of properties you can configure. Also note that you can define more You can refer to [[yii\db\Connection]] for a list of properties you can configure. Also note that you can define more
than one connection component and use both at the same time if needed: than one connection component and use both at the same time if needed:
```php ```php
...@@ -96,7 +96,7 @@ return [ ...@@ -96,7 +96,7 @@ return [
Basic SQL queries Basic SQL queries
----------------- -----------------
Once you have a connection instance you can execute SQL queries using [[\yii\db\Command]]. Once you have a connection instance you can execute SQL queries using [[yii\db\Command]].
### SELECT ### SELECT
...@@ -173,8 +173,8 @@ $rowCount = $connection->createCommand($sql)->queryScalar(); ...@@ -173,8 +173,8 @@ $rowCount = $connection->createCommand($sql)->queryScalar();
In the code above `[[X]]` will be converted to properly quoted column name while `{{Y}}` will be converted to properly In the code above `[[X]]` will be converted to properly quoted column name while `{{Y}}` will be converted to properly
quoted table name. quoted table name.
The alternative is to quote table and column names manually using [[\yii\db\Connection::quoteTableName()]] and The alternative is to quote table and column names manually using [[yii\db\Connection::quoteTableName()]] and
[[\yii\db\Connection::quoteColumnName()]]: [[yii\db\Connection::quoteColumnName()]]:
```php ```php
$column = $connection->quoteColumnName($column); $column = $connection->quoteColumnName($column);
...@@ -253,7 +253,7 @@ Working with database schema ...@@ -253,7 +253,7 @@ Working with database schema
### Getting schema information ### Getting schema information
You can get a [[\yii\db\Schema]] instance like the following: You can get a [[yii\db\Schema]] instance like the following:
```php ```php
$schema = $connection->getSchema(); $schema = $connection->getSchema();
...@@ -265,11 +265,11 @@ It contains a set of methods allowing you to retrieve various information about ...@@ -265,11 +265,11 @@ It contains a set of methods allowing you to retrieve various information about
$tables = $schema->getTableNames(); $tables = $schema->getTableNames();
``` ```
For the full reference check [[\yii\db\Schema]]. For the full reference check [[yii\db\Schema]].
### Modifying schema ### Modifying schema
Aside from basic SQL queries [[\yii\db\Command]] contains a set of methods allowing to modify database schema: Aside from basic SQL queries [[yii\db\Command]] contains a set of methods allowing to modify database schema:
- createTable, renameTable, dropTable, truncateTable - createTable, renameTable, dropTable, truncateTable
- addColumn, renameColumn, dropColumn, alterColumn - addColumn, renameColumn, dropColumn, alterColumn
...@@ -288,4 +288,4 @@ $connection->createCommand()->createTable('tbl_post', [ ...@@ -288,4 +288,4 @@ $connection->createCommand()->createTable('tbl_post', [
]); ]);
``` ```
For the full reference check [[\yii\db\Command]]. For the full reference check [[yii\db\Command]].
...@@ -40,7 +40,7 @@ $component->on($eventName, function($event) { ...@@ -40,7 +40,7 @@ $component->on($eventName, function($event) {
``` ```
As shown in the anonymous function example, the event handling function must be defined so that it takes one argument. As shown in the anonymous function example, the event handling function must be defined so that it takes one argument.
This will be an [[\yii\base\Event]] object. This will be an [[yii\base\Event]] object.
Removing Event Handlers Removing Event Handlers
......
...@@ -2,7 +2,7 @@ Working with forms ...@@ -2,7 +2,7 @@ Working with forms
================== ==================
The primary way of using forms in Yii is through [[yii\widgets\ActiveForm]]. This approach should be preferred when The primary way of using forms in Yii is through [[yii\widgets\ActiveForm]]. This approach should be preferred when
the form is based upon a model. Additionally, there are some useful methods in [[\yii\helpers\Html]] that are typically the form is based upon a model. Additionally, there are some useful methods in [[yii\helpers\Html]] that are typically
used for adding buttons and help text to any form. used for adding buttons and help text to any form.
When creating model-based forms, the first step is to define the model itself. The model can be either based upon the When creating model-based forms, the first step is to define the model itself. The model can be either based upon the
......
...@@ -8,8 +8,8 @@ because the potential users may be worldwide. ...@@ -8,8 +8,8 @@ because the potential users may be worldwide.
Locale and Language Locale and Language
------------------- -------------------
There are two languages defined in Yii application: [[\yii\base\Application::$sourceLanguage|source language]] and There are two languages defined in Yii application: [[yii\base\Application::$sourceLanguage|source language]] and
[[\yii\base\Application::$language|target language]]. [[yii\base\Application::$language|target language]].
Source language is the language original application messages are written in such as: Source language is the language original application messages are written in such as:
......
...@@ -62,7 +62,7 @@ You may configure the targets in application configuration, like the following: ...@@ -62,7 +62,7 @@ You may configure the targets in application configuration, like the following:
] ]
``` ```
In the config above we are defining two log targets: [[\yii\log\FileTarget|file]] and [[\yii\log\EmailTarget|email]]. In the config above we are defining two log targets: [[yii\log\FileTarget|file]] and [[yii\log\EmailTarget|email]].
In both cases we are filtering messages handles by these targets by severity. In case of file target we're In both cases we are filtering messages handles by these targets by severity. In case of file target we're
additionally filter by category. `yii\*` means all categories starting with `yii\`. additionally filter by category. `yii\*` means all categories starting with `yii\`.
......
...@@ -9,7 +9,7 @@ Yii models have the following basic features: ...@@ -9,7 +9,7 @@ Yii models have the following basic features:
- Massive attribute assignment: the ability to populate multiple model attributes in one step. - Massive attribute assignment: the ability to populate multiple model attributes in one step.
- Scenario-based data validation. - Scenario-based data validation.
Models in Yii extend from the [[\yii\base\Model]] class. Models are typically used to both hold data and define Models in Yii extend from the [[yii\base\Model]] class. Models are typically used to both hold data and define
the validation rules for that data (aka, the business logic). The business logic greatly simplifies the generation the validation rules for that data (aka, the business logic). The business logic greatly simplifies the generation
of models from complex web forms by providing validation and error reporting. of models from complex web forms by providing validation and error reporting.
...@@ -31,7 +31,7 @@ echo $post->title; ...@@ -31,7 +31,7 @@ echo $post->title;
echo $post->content; echo $post->content;
``` ```
Since [[\yii\base\Model|Model]] implements the [ArrayAccess](http://php.net/manual/en/class.arrayaccess.php) interface, Since [[yii\base\Model|Model]] implements the [ArrayAccess](http://php.net/manual/en/class.arrayaccess.php) interface,
you can also access the attributes as if they were array elements: you can also access the attributes as if they were array elements:
```php ```php
...@@ -42,7 +42,7 @@ echo $post['title']; ...@@ -42,7 +42,7 @@ echo $post['title'];
echo $post['content']; echo $post['content'];
``` ```
By default, [[\yii\base\Model|Model]] requires that attributes be declared as *public* and *non-static* By default, [[yii\base\Model|Model]] requires that attributes be declared as *public* and *non-static*
class member variables. In the following example, the `LoginForm` model class declares two attributes: class member variables. In the following example, the `LoginForm` model class declares two attributes:
`username` and `password`. `username` and `password`.
...@@ -55,8 +55,8 @@ class LoginForm extends \yii\base\Model ...@@ -55,8 +55,8 @@ class LoginForm extends \yii\base\Model
} }
``` ```
Derived model classes may declare attributes in different ways, by overriding the [[\yii\base\Model::attributes()|attributes()]] Derived model classes may declare attributes in different ways, by overriding the [[yii\base\Model::attributes()|attributes()]]
method. For example, [[\yii\db\ActiveRecord]] defines attributes using the column names of the database table method. For example, [[yii\db\ActiveRecord]] defines attributes using the column names of the database table
that is associated with the class. that is associated with the class.
...@@ -65,12 +65,12 @@ Attribute Labels ...@@ -65,12 +65,12 @@ Attribute Labels
Attribute labels are mainly used for display purpose. For example, given an attribute `firstName`, we can declare Attribute labels are mainly used for display purpose. For example, given an attribute `firstName`, we can declare
a label `First Name` that is more user-friendly when displayed to end users in places such as form labels and a label `First Name` that is more user-friendly when displayed to end users in places such as form labels and
error messages. Given an attribute name, you can obtain its label by calling [[\yii\base\Model::getAttributeLabel()]]. error messages. Given an attribute name, you can obtain its label by calling [[yii\base\Model::getAttributeLabel()]].
To declare attribute labels, override the [[\yii\base\Model::attributeLabels()]] method. The overridden method returns To declare attribute labels, override the [[yii\base\Model::attributeLabels()]] method. The overridden method returns
a mapping of attribute names to attribute labels, as shown in the example below. If an attribute is not found a mapping of attribute names to attribute labels, as shown in the example below. If an attribute is not found
in this mapping, its label will be generated using the [[\yii\base\Model::generateAttributeLabel()]] method. in this mapping, its label will be generated using the [[yii\base\Model::generateAttributeLabel()]] method.
In many cases, [[\yii\base\Model::generateAttributeLabel()]] will generate reasonable labels (e.g. `username` to `Username`, In many cases, [[yii\base\Model::generateAttributeLabel()]] will generate reasonable labels (e.g. `username` to `Username`,
`orderNumber` to `Order Number`). `orderNumber` to `Order Number`).
```php ```php
...@@ -200,7 +200,7 @@ if ($model->validate()) { ...@@ -200,7 +200,7 @@ if ($model->validate()) {
The possible validation rules for a model should be listed in its `rules()` method. Each validation rule applies to one The possible validation rules for a model should be listed in its `rules()` method. Each validation rule applies to one
or several attributes and is effective in one or several scenarios. A rule can be specified using a validator object - an or several attributes and is effective in one or several scenarios. A rule can be specified using a validator object - an
instance of a [[\yii\validators\Validator]] child class, or an array with the following format: instance of a [[yii\validators\Validator]] child class, or an array with the following format:
```php ```php
[ [
...@@ -449,4 +449,4 @@ See also ...@@ -449,4 +449,4 @@ See also
-------- --------
- [Model validation reference](validation.md) - [Model validation reference](validation.md)
- [[\yii\base\Model]] - [[yii\base\Model]]
...@@ -137,7 +137,7 @@ sending either `ETag` or `Last-Modified` header in your application response. If ...@@ -137,7 +137,7 @@ sending either `ETag` or `Last-Modified` header in your application response. If
HTTP specification (most browsers are), content will be fetched only if it is different from what it was prevously. HTTP specification (most browsers are), content will be fetched only if it is different from what it was prevously.
Forming proper headers is time consuming task so Yii provides a shortcut in form of controller filter Forming proper headers is time consuming task so Yii provides a shortcut in form of controller filter
[[\yii\web\HttpCache]]. Using it is very easy. In a controller you need to implement `behaviors` method like [[yii\web\HttpCache]]. Using it is very easy. In a controller you need to implement `behaviors` method like
the following: the following:
```php ```php
......
...@@ -205,8 +205,8 @@ In this way you will avoid collision of fixture data files between tests and use ...@@ -205,8 +205,8 @@ In this way you will avoid collision of fixture data files between tests and use
> Note: In the example above fixture files are named only for example purpose. In real life you should name them > Note: In the example above fixture files are named only for example purpose. In real life you should name them
> according to which fixture class your fixture classes are extending from. For example, if you are extending > according to which fixture class your fixture classes are extending from. For example, if you are extending
> from [[\yii\test\ActiveFixture]] for DB fixtures, you should use DB table names as the fixture data file names; > from [[yii\test\ActiveFixture]] for DB fixtures, you should use DB table names as the fixture data file names;
> If you are extending for [[\yii\mongodb\ActiveFixture]] for MongoDB fixtures, you should use collection names as the file names. > If you are extending for [[yii\mongodb\ActiveFixture]] for MongoDB fixtures, you should use collection names as the file names.
The similar hierarchy can be used to organize fixture class files. Instead of using `data` as the root directory, you may The similar hierarchy can be used to organize fixture class files. Instead of using `data` as the root directory, you may
want to use `fixtures` as the root directory to avoid conflict with the data files. want to use `fixtures` as the root directory to avoid conflict with the data files.
......
...@@ -192,10 +192,10 @@ return [ ...@@ -192,10 +192,10 @@ return [
### Handling REST requests ### Handling REST requests
TBD: TBD:
- RESTful routing: [[\yii\web\VerbFilter]], [[\yii\web\UrlManager::$rules]] - RESTful routing: [[yii\web\VerbFilter]], [[yii\web\UrlManager::$rules]]
- Json API: - Json API:
- response: [[\yii\web\Response::format]] - response: [[yii\web\Response::format]]
- request: [[yii\web\Request::$parsers]], [[\yii\web\JsonParser]] - request: [[yii\web\Request::$parsers]], [[yii\web\JsonParser]]
URL parsing URL parsing
...@@ -222,13 +222,13 @@ return [ ...@@ -222,13 +222,13 @@ return [
Creating your own rule classes Creating your own rule classes
------------------------------ ------------------------------
[[\yii\web\UrlRule]] class is used for both parsing URL into parameters and creating URL based on parameters. Despite [[yii\web\UrlRule]] class is used for both parsing URL into parameters and creating URL based on parameters. Despite
the fact that default implementation is flexible enough for the majority of projects, there are situations when using the fact that default implementation is flexible enough for the majority of projects, there are situations when using
your own rule class is the best choice. For example, in a car dealer website, we may want to support the URL format like your own rule class is the best choice. For example, in a car dealer website, we may want to support the URL format like
`/Manufacturer/Model`, where `Manufacturer` and `Model` must both match some data in a database table. The default rule `/Manufacturer/Model`, where `Manufacturer` and `Model` must both match some data in a database table. The default rule
class will not work because it mostly relies on statically declared regular expressions which have no database knowledge. class will not work because it mostly relies on statically declared regular expressions which have no database knowledge.
We can write a new URL rule class by extending from [[\yii\web\UrlRule]] and use it in one or multiple URL rules. Using We can write a new URL rule class by extending from [[yii\web\UrlRule]] and use it in one or multiple URL rules. Using
the above car dealer website as an example, we may declare the following URL rules in application config: the above car dealer website as an example, we may declare the following URL rules in application config:
```php ```php
......
...@@ -166,7 +166,7 @@ Validates that the attribute value is of certain length. ...@@ -166,7 +166,7 @@ Validates that the attribute value is of certain length.
- `length` specifies the length limit of the value to be validated. Can be `exactly X`, `[min X]`, `[min X, max Y]`. - `length` specifies the length limit of the value to be validated. Can be `exactly X`, `[min X]`, `[min X, max Y]`.
- `max` maximum length. If not set, it means no maximum length limit. - `max` maximum length. If not set, it means no maximum length limit.
- `min` minimum length. If not set, it means no minimum length limit. - `min` minimum length. If not set, it means no minimum length limit.
- `encoding` the encoding of the string value to be validated. _([[\yii\base\Application::charset]])_ - `encoding` the encoding of the string value to be validated. _([[yii\base\Application::charset]])_
### `unique`: [[yii\validators\UniqueValidator|UniqueValidator]] ### `unique`: [[yii\validators\UniqueValidator|UniqueValidator]]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment