本文整理汇总了PHP中yii\rest\ActiveController::init方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveController::init方法的具体用法?PHP ActiveController::init怎么用?PHP ActiveController::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\rest\ActiveController
的用法示例。
在下文中一共展示了ActiveController::init方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
if (!$this->modelName) {
$this->modelName = StringHelper::basename(get_class($this), 'Controller');
}
if (!$this->modelClass) {
$modelClass = 'app\\models\\' . $this->modelName;
if (class_exists($modelClass)) {
$this->modelClass = $modelClass;
} else {
$modelClass = 'app\\models\\readonly\\' . $this->modelName;
if (class_exists($modelClass)) {
$this->modelClass = $modelClass;
}
}
}
if (!$this->filterModelClass) {
$filterModelClass = 'app\\models\\search\\' . $this->modelName . 'Search';
if (class_exists($filterModelClass)) {
$this->filterModelClass = $filterModelClass;
} else {
$filterModelClass = 'app\\models\\readonly\\search\\' . $this->modelName . 'Search';
if (class_exists($filterModelClass)) {
$this->filterModelClass = $filterModelClass;
}
}
}
parent::init();
}
示例2: init
public function init()
{
if (!$this->modelClass) {
$this->modelClass = Inflector::pluralize($this->id);
}
\Yii::$app->request->getRawBody();
\Yii::$app->getResponse()->getHeaders()->add('Access-Control-Allow-Origin', '*');
parent::init();
}
示例3: init
public function init()
{
parent::init();
if ($this->relationAttribute === null) {
throw new InvalidConfigException('The "relationAttribute" property must be set.');
}
if ($this->relations === null) {
throw new InvalidConfigException('The "relations" property must be set.');
}
if ($this->searchClass === null) {
throw new InvalidConfigException('The "searchClass" property must be set.');
}
}
示例4: init
public function init()
{
parent::init();
XiiVersion::run(self::XII_VERSION);
if ($this->modelClass === 'XiiAcPlus') {
XiiError::sendError(0, 'The "modelClass" property must be set.');
Yii::$app->end();
}
$this->_requestCurrent = Yii::$app->request->getMethod();
XiiError::open();
$this->_modelClass = new $this->modelClass();
switch ($this->_requestCurrent) {
case 'GET':
$this->_requestData = Yii::$app->request->get();
$this->_requestIds = isset($this->_requestData['id']) ? $this->_requestData['id'] : '';
break;
case 'POST':
$this->_requestData = Yii::$app->request->post();
break;
case 'PUT':
parse_str(file_get_contents('php://input'), $put_vars);
$this->_requestData = $put_vars;
$this->_requestIds = Yii::$app->request->get();
$this->_requestData = array_merge($this->_requestData, $this->_requestIds);
break;
case 'DELETE':
parse_str(file_get_contents('php://input'), $put_vars);
$this->_requestData = $put_vars;
$this->_requestIds = Yii::$app->request->get();
break;
default:
$this->_requestData = Null;
break;
}
if (isset($this->_requestData[$this->_requestValidField])) {
$this->_requestValidData[$this->_requestValidField] = $this->_requestData[$this->_requestValidField];
unset($this->_requestData[$this->_requestValidField]);
}
}
示例5: init
public function init()
{
Yii::$app->response->format = Response::FORMAT_JSON;
parent::init();
}
示例6: init
public function init()
{
parent::init();
Yii::$app->user->enableSession = false;
Yii::$app->response->format = 'json';
}
示例7: init
public function init()
{
parent::init();
Yii::$app->user->enableSession = false;
}
示例8: init
/**
* Initializer of the controller
*
**/
public function init()
{
parent::init();
}
示例9: init
public function init()
{
return parent::init();
$this->checkHeader()->setSessionID();
}
示例10: init
public function init()
{
parent::init();
\Yii::$app->user->enableSession = false;
\Yii::$app->user->loginUrl = null;
}