this is my ActionTimeFilter, so how can I configure it in web.php to enable every action to pass through this filter? Wait online. I"ve been in a hurry all day. Is it so good?
<?php
namespace app\filters;
use Yii;
use yii\base\Action;
use yii\base\ActionFilter;
class ActionTimeFilter extends ActionFilter
{
private $_startTime;
public function beforeAction($action)
{
Yii::info("2222222222222");
$this->_startTime = microtime(true);
return array(
"dd"=>2
);
return parent::beforeAction($action);
// return parent::beforeAction($action);
}
public function afterAction($action, $result)
{
$time = microtime(true) - $this->_startTime;
Yii::debug("Action "{$action->uniqueId}" spent $time second.");
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
return array(
"dd"=>2
);
// $time = microtime(true) - $this->_startTime;
// Yii::debug("Action "{$action->uniqueId}" spent $time second.");
// Yii::$app->response->format=Response::FORMAT_JSON;
return parent::afterAction($action, $result);
}
}