Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #602 from kbrodej/hotfix/Drupal-class-avoid-#547
Browse files Browse the repository at this point in the history
Added dependency injection for EntityTypeManager instead \Drupal calls
  • Loading branch information
pfrenssen authored Feb 7, 2020
2 parents 94e67d7 + da52bba commit b0349d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 0 additions & 2 deletions phpcs-ruleset.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
<exclude name="DrupalPractice.InfoFiles.NamespacedDependency.NonNamespaced" />
<!-- https://github.com/Gizra/og/issues/546 -->
<exclude name="DrupalPractice.Objects.GlobalClass.GlobalClass" />
<!-- https://github.com/Gizra/og/issues/547 -->
<exclude name="DrupalPractice.Objects.GlobalDrupal.GlobalDrupal" />
<!-- https://github.com/Gizra/og/issues/543 -->
<exclude name="DrupalPractice.Objects.GlobalFunction.GlobalFunction" />
</rule>
Expand Down
10 changes: 9 additions & 1 deletion src/GroupTypeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ class GroupTypeManager implements GroupTypeManagerInterface {
*/
protected $groupAudienceHelper;

/**
* The Entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;

/**
* Constructs a GroupTypeManager object.
*
Expand All @@ -155,6 +162,7 @@ class GroupTypeManager implements GroupTypeManagerInterface {
*/
public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, EventDispatcherInterface $event_dispatcher, CacheBackendInterface $cache, PermissionManagerInterface $permission_manager, OgRoleManagerInterface $og_role_manager, RouteBuilderInterface $route_builder, OgGroupAudienceHelperInterface $group_audience_helper) {
$this->configFactory = $config_factory;
$this->entityTypeManager = $entity_type_manager;
$this->entityTypeBundleInfo = $entity_type_bundle_info;
$this->eventDispatcher = $event_dispatcher;
$this->cache = $cache;
Expand Down Expand Up @@ -377,7 +385,7 @@ protected function populateGroupRelationMap(): void {

$this->groupRelationMap = [];

$user_bundles = \Drupal::entityTypeManager()->getDefinition('user')->getKey('bundle') ?: ['user'];
$user_bundles = $this->entityTypeManager->getDefinition('user')->getKey('bundle') ?: ['user'];

foreach ($this->entityTypeBundleInfo->getAllBundleInfo() as $group_content_entity_type_id => $bundles) {
foreach ($bundles as $group_content_bundle_id => $bundle_info) {
Expand Down

0 comments on commit b0349d6

Please sign in to comment.