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

Added dependency injection for EntityTypeManager instead \Drupal calls #602

Merged
merged 3 commits into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions phpcs-ruleset.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,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