beforeAction() public method

This method is invoked right before an action is to be executed (after all possible filters.) You may override this method to do last-minute preparation for the action.
public beforeAction ( Action $action ) : boolean
$action yii\base\Action the action to be executed.
return boolean whether the action should continue to be executed.
Beispiel #1
0
 /**
  * @covers yii\filters\HttpCache::generateEtag
  */
 public function testGenerateEtag()
 {
     $httpCache = new HttpCache();
     $httpCache->etagSeed = function ($action, $params) {
         return '';
     };
     $httpCache->beforeAction(null);
     $response = Yii::$app->getResponse();
     $this->assertTrue($response->getHeaders()->offsetExists('ETag'));
     $etag = $response->getHeaders()->get('ETag');
     $this->assertStringStartsWith('"', $etag);
     $this->assertStringEndsWith('"', $etag);
 }