NEW Filter out authenticators that are falsy

Use-case: if a module is defining its own authenticator and you want to disable it, as it seems we don't have `unregister_authenticator()` anymore and I can't spot how to remove YAML-based injected properties, then this lets you mark it as null or false to prevent it from erroring out when it attempts to call `supportedServices()`
This commit is contained in:
Indy Griffiths 2019-05-02 23:35:48 +12:00 committed by Indy Griffiths
parent 2e5c7b9f2d
commit 5dc57518c2
No known key found for this signature in database
GPG Key ID: 4BDD1C0E13DB19C3

View File

@ -202,7 +202,7 @@ class Security extends Controller implements TemplateGlobalProvider
*/ */
public function getAuthenticators() public function getAuthenticators()
{ {
return $this->authenticators; return array_filter($this->authenticators);
} }
/** /**
@ -244,7 +244,7 @@ class Security extends Controller implements TemplateGlobalProvider
*/ */
protected function getAuthenticator($name = 'default') protected function getAuthenticator($name = 'default')
{ {
$authenticators = $this->authenticators; $authenticators = $this->getAuthenticators();
if (isset($authenticators[$name])) { if (isset($authenticators[$name])) {
return $authenticators[$name]; return $authenticators[$name];
@ -286,7 +286,7 @@ class Security extends Controller implements TemplateGlobalProvider
*/ */
public function hasAuthenticator($authenticator) public function hasAuthenticator($authenticator)
{ {
$authenticators = $this->authenticators; $authenticators = $this->getAuthenticators();
return !empty($authenticators[$authenticator]); return !empty($authenticators[$authenticator]);
} }