public function beforeAction($action)
{
$allowedHosts = $this->allowedHosts;
if ($allowedHosts instanceof \Closure) {
$allowedHosts = call_user_func($allowedHosts, $action);
}
if ($allowedHosts === null) {
return true;
}
if (!is_array($allowedHosts) && !$allowedHosts instanceof \Traversable) {
$allowedHosts = (array) $allowedHosts;
}
$currentHost = Yii::$app->getRequest()->getHostName();
foreach ($allowedHosts as $allowedHost) {
if (fnmatch($allowedHost, $currentHost)) {
return true;
}
}
if ($this->denyCallback !== null) {
call_user_func($this->denyCallback, $action);
} else {
$this->denyAccess($action);
}
return false;
}