public function hasAccess($expression)
{
$user = $this;
if ($this->isAdministrator() || empty($expression)) {
return true;
}
if (!preg_match('/[&\\(\\)\\|\\!]/', $expression)) {
return $this->hasPermission($expression);
}
$exp = preg_replace('/[^01&\\(\\)\\|!]/', '', preg_replace_callback('/[a-z_][a-z-_\\.:\\d\\s]*/i', function ($permission) use($user) {
return (int) $user->hasPermission(trim($permission[0]));
}, $expression));
if (!($fn = @create_function("", "return {$exp};"))) {
throw new \InvalidArgumentException(sprintf('Unable to parse the given access string "%s"', $expression));
}
return (bool) $fn();
}