Skip to content

Commit

Permalink
Merge pull request #2 from uiowa/remove_circular_dependency_injection
Browse files Browse the repository at this point in the history
Remove problematic dependency injection
  • Loading branch information
pyrello authored Aug 18, 2022
2 parents d93f30f + 548d4d7 commit 0f9fb39
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
16 changes: 1 addition & 15 deletions src/ConfigOverride/SamlauthOverride.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,11 @@
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Config\ConfigFactoryOverrideInterface;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;

/**
* Samlauth configuration overrides.
*/
class SamlauthOverride implements ConfigFactoryOverrideInterface {
/**
* The entity_type.manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;

/**
* {@inheritdoc}
*/
public function __construct(EntityTypeManagerInterface $entityTypeManager) {
$this->entityTypeManager = $entityTypeManager;
}

/**
* {@inheritdoc}
Expand All @@ -34,7 +20,7 @@ public function loadOverrides($names) {
// Allow all roles to be linkable.
if (in_array('samlauth.authentication', $names)) {

$roles = $this->entityTypeManager->getStorage('user_role')->loadMultiple();
$roles = \Drupal::service('entity_type.manager')->getStorage('user_role')->loadMultiple();
$allowed = [];

/** @var \Drupal\user\Entity\Role $role */
Expand Down
10 changes: 9 additions & 1 deletion tests/build/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"symfony/phpunit-bridge": "^5.2",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"drupal/coder": "^8.3",
"mglaman/drupal-check": "^1.1",
"mglaman/drupal-check": "~1.3.1",
"oomphinc/composer-installers-extender": "^2.0",
"phpspec/prophecy-phpunit": "^2.0"
},
Expand Down Expand Up @@ -50,5 +50,13 @@
"Drupal\\uiowa_auth\\": "docroot/modules/custom/uiowa_auth/src/",
"Drupal\\Tests\\uiowa_auth\\": "docroot/modules/custom/uiowa_auth/tests/"
}
},
"config": {
"allow-plugins": {
"composer/installers": true,
"drupal/core-composer-scaffold": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"oomphinc/composer-installers-extender": true
}
}
}
1 change: 0 additions & 1 deletion uiowa_auth.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ services:
- { name: event_subscriber }
uiowa_auth.samlauth_override:
class: Drupal\uiowa_auth\ConfigOverride\SamlauthOverride
arguments: [ '@entity_type.manager' ]
tags:
- { name: config.factory.override }

0 comments on commit 0f9fb39

Please sign in to comment.