Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove problematic dependency injection #2

Merged
merged 13 commits into from
Aug 18, 2022
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 }