ただのアイデア。AOP パラダイム (JMSAopBundle) はどうですか? コントローラーのポイントカットを定義します (ログイン コントローラーを除く)。
class PrivateEntityInformationPointcut implements PointcutInterface
{
public function matchesClass(\ReflectionClass $class)
{
return $class->isSubclassOf('Your\Controller\Superclass')
&& $class->name !== 'Your\Controller\Access';
}
public function matchesMethod(\ReflectionMethod $method)
{
return true; // Any method
}
}
次に、インターセプターはユーザー名を設定するためのページにリダイレクトする必要があります。
class DenyEntityAccessInterceptor implements MethodInterceptorInterface
{
private $securityContext;
private $logger;
/**
* @DI\InjectParams({
* "securityContext" = @DI\Inject("security.context"),
* "logger" = @DI\Inject("logger"),
* })
*/
public function __construct(SecurityContext $securityContext,
Logger $logger)
{
$this->securityContext = $securityContext;
$this->logger = $logger;
}
public function intercept(MethodInvocation $invocation)
{
// Check username, redirect using the router, log what's happening
// It's OK
return $invocation->proceed();
}
}