private ContainerInterface
$locator;
private RequestStack
$requestStack;
private FirewallMap
$firewallMap;
private function getForFirewall(): object
{ $serviceIdentifier =
str_replace('FirewallAware', '',
static::
class);
if (null ===
$request =
$this->requestStack->
getCurrentRequest()) { throw new \
LogicException('Cannot determine the correct '.
$serviceIdentifier.' to use: there is no active Request and so, the firewall cannot be determined. Try using a specific '.
$serviceIdentifier.' service.'
);
} $firewall =
$this->firewallMap->
getFirewallConfig($request);
if (!
$firewall) { throw new \
LogicException('No '.
$serviceIdentifier.' found as the current route is not covered by a firewall.'
);
} $firewallName =
$firewall->
getName();
if (!
$this->locator->
has($firewallName)) { $message = 'No '.
$serviceIdentifier.' found for this firewall.';
if (\
defined(static::
class.'::FIREWALL_OPTION'
)) { $message .=
sprintf('Did you forget to add a "'.
static::FIREWALL_OPTION.'" key under your "%s" firewall?',
$firewallName);
}