for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @copyright Copyright (c) Flipbox Digital Limited
* @license https://github.com/flipbox/spark/blob/master/LICENSE
* @link https://github.com/flipbox/spark
*/
namespace flipbox\spark\actions\traits;
use yii\web\HttpException;
* @author Flipbox Factory <[email protected]>
* @since 1.0.0
trait CheckAccess
{
* @var int
public $accessCodeUnauthorized = 403;
* @var null|callable
public $checkAccess = null;
* @param array ...$params
* @return mixed
public function checkAccess(...$params)
if ($this->checkAccess) {
if (call_user_func_array($this->checkAccess, $params) === false) {
return $this->handleUnauthorizedResponse();
};
}
return true;
* @throws HttpException
protected function handleUnauthorizedResponse()
throw new HttpException(
$this->accessCodeUnauthorized,
'Unable to perform action.'
);