rest\Action findModel()

findModel() public method Returns the data model based on the primary key given. If the data model is not found, a 404 HTTP exception will be raised. public yii\db\ActiveRecordInterface findModel ( $id )$id string The ID of the model to be loaded. If the model has a composite primary key, the ID must be a string of the primary key values separated by commas. The order of the primary key values should follow that returned by the primaryKey() method of the model. return yii\db\ActiveRecor

rest\Action init()

init() public method Initializes the object. This method is invoked at the end of the constructor after the object is initialized with the given configuration. public void init ( )

rest\Action $findModel

$findModel public property A PHP callable that will be called to return the model corresponding to the specified primary key value. If not set, findModel() will be used instead. The signature of the callable should be: function ($id, $action) { // $id is the primary key value. If composite primary key, the key values // will be separated by comma. // $action is the action object currently running } The callable should return the model found, or throw an exception if not found.

rest\Action $checkAccess

$checkAccess public property A PHP callable that will be called when running an action to determine if the current user has the permission to execute the action. If not set, the access check will not be performed. The signature of the callable should be as follows, function ($action, $model = null) { // $model is the requested model instance. // If null, it means no specific model (e.g. IndexAction) } public callable $checkAccess = null

rest\Action $modelClass

$modelClass public property Class name of the model which will be handled by this action. The model class must implement yii\db\ActiveRecordInterface. This property must be set. public string $modelClass = null

Responses

Status Code HTTP Headers Response Body Browser Redirection Sending Files Sending Response When an application finishes handling a request, it generates a response object and sends it to the end user. The response object contains information such as the HTTP status code, HTTP headers and body. The ultimate goal of Web application development is essentially to build such response objects upon various requests. In most cases you should mainly deal with the response application component which is

Response Formatting

Content Negotiation Data Serializing When handling a RESTful API request, an application usually takes the following steps that are related with response formatting: Determine various factors that may affect the response format, such as media type, language, version, etc. This process is also known as content negotiation. Convert resource objects into arrays, as described in the Resources section. This is done by yii\rest\Serializer. Convert arrays into a string in the format as determined by

Resources

Fields Links Collections RESTful APIs are all about accessing and manipulating resources. You may view resources as models in the MVC paradigm. While there is no restriction in how to represent a resource, in Yii you usually would represent resources in terms of objects of yii\base\Model or its child classes (e.g. yii\db\ActiveRecord), for the following reasons: yii\base\Model implements the yii\base\Arrayable interface, which allows you to customize how you want to expose resource data throu

Requests

Request Parameters Request Methods Request URLs HTTP Headers Client Information Requests made to an application are represented in terms of yii\web\Request objects which provide information such as request parameters, HTTP headers, cookies, etc. For a given request, you can get access to the corresponding request object via the request application component which is an instance of yii\web\Request, by default. In this section, we will describe how you can make use of this component in your appl

redis\Session getUseCustomStorage()

getUseCustomStorage() public method Returns a value indicating whether to use custom session storage. This method overrides the parent implementation and always returns true. public boolean getUseCustomStorage ( )return boolean Whether to use custom storage.