public function vote(TokenInterface $token, $object, array $attributes)
{
$request = null;
try {
$request = $this->app['request'];
} catch (\RuntimeException $e) {
// requestが取得できない場合、無視する(テストプログラムで不要なため)
return;
}
$path = rawurldecode($request->getPathInfo());
$Member = $this->app->user();
if ($Member instanceof \Eccube\Entity\Member) {
// 管理者のロールをチェック
$AuthorityRoles = $this->app['eccube.repository.authority_role']->findBy(array('Authority' => $Member->getAuthority()));
foreach ($AuthorityRoles as $AuthorityRole) {
// 許可しないURLが含まれていればアクセス拒否
try {
// 正規表現でURLチェック
$denyUrl = str_replace('/', '\\/', $AuthorityRole->getDenyUrl());
if (preg_match("/^(\\/{$this->app['config']['admin_route']}{$denyUrl})/i", $path)) {
return VoterInterface::ACCESS_DENIED;
}
} catch (\Exception $e) {
// 拒否URLの指定に誤りがある場合、エスケープさせてチェック
$denyUrl = preg_quote($AuthorityRole->getDenyUrl(), '/');
if (preg_match("/^(\\/{$this->app['config']['admin_route']}{$denyUrl})/i", $path)) {
return VoterInterface::ACCESS_DENIED;
}
}
}
}
return VoterInterface::ACCESS_GRANTED;
}