Skip to content
Snippets Groups Projects

Issue #3511840: TfaPluginManager should use ConfigFactory not ImmutableConfig

Merged Conrad Lara requested to merge issue/tfa-3511840:3511840-tfapluginmanager-should-use into 2.x
1 file
+ 3
12
Compare changes
  • Side-by-side
  • Inline
+ 3
12
@@ -4,7 +4,6 @@ namespace Drupal\tfa;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ImmutableConfig;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
@@ -15,13 +14,6 @@ use Drupal\Core\Plugin\DefaultPluginManager;
*/
class TfaPluginManager extends DefaultPluginManager {
/**
* TFA configuration object.
*
* @var \Drupal\Core\Config\ImmutableConfig
*/
protected ImmutableConfig $tfaSettings;
/**
* Constructs TfaPluginManager object.
*
@@ -32,10 +24,10 @@ class TfaPluginManager extends DefaultPluginManager {
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* The config factory.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory) {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, protected ConfigFactoryInterface $configFactory) {
parent::__construct(
'Plugin/Tfa',
$namespaces,
@@ -45,7 +37,6 @@ class TfaPluginManager extends DefaultPluginManager {
);
$this->alterInfo('tfa_info');
$this->setCacheBackend($cache_backend, 'tfa_plugins');
$this->tfaSettings = $config_factory->get('tfa.settings');
}
/**
@@ -70,7 +61,7 @@ class TfaPluginManager extends DefaultPluginManager {
public function getLoginDefinitions(bool $active_only = TRUE): array {
$plugins = $this->getClassDefinitions('\Drupal\tfa\Plugin\TfaLoginInterface');
if ($active_only) {
$login_plugins = $this->tfaSettings->get('login_plugins');
$login_plugins = $this->configFactory->get('tfa.settings')->get('login_plugins');
$plugins = array_filter($plugins, function (array $plugin) use ($login_plugins) {
return ($login_plugins[$plugin['id']] ?? NULL) === $plugin['id'];
});
Loading