Skip to content

Commit

Permalink
Merge pull request #2 from kbrodej/DI-#546
Browse files Browse the repository at this point in the history
Remove unnecessary dependency injection
  • Loading branch information
kbrodej committed Feb 7, 2020
2 parents 03bb400 + f150ff4 commit 2beb2c3
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions src/Controller/SubscriptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,17 @@ class SubscriptionController extends ControllerBase {
*/
protected $messenger;

/**
* Entity type manager service.
*
* @var \Drupal\Core\Entity\EntityStorageInterface|mixed|object
* Gets storage of user.
*/
protected $entityTypeManager;

/**
* Constructs a SubscriptionController object.
*
* @param \Drupal\og\OgAccessInterface $og_access
* The OG access service.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger service.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function __construct(OgAccessInterface $og_access, MessengerInterface $messenger, EntityTypeManagerInterface $entity_type_manager) {
public function __construct(OgAccessInterface $og_access, MessengerInterface $messenger) {
$this->ogAccess = $og_access;
$this->messenger = $messenger;
$this->entityTypeManager = $entity_type_manager->getStorage('user');
}

/**
Expand All @@ -69,8 +55,7 @@ public function __construct(OgAccessInterface $og_access, MessengerInterface $me
public static function create(ContainerInterface $container) {
return new static(
$container->get('og.access'),
$container->get('messenger'),
$container->get('entity_type.manager')
$container->get('messenger')
);
}

Expand Down Expand Up @@ -99,7 +84,7 @@ public function subscribe($entity_type_id, EntityInterface $group, OgMembershipT
throw new AccessDeniedHttpException();
}

$user = $this->entityTypeManager->load($this->currentUser()->id());
$user = $this->entityTypeManager()->getStorage('user')->load($this->currentUser()->id());

if ($user->isAnonymous()) {
// Anonymous user can't request membership.
Expand Down

0 comments on commit 2beb2c3

Please sign in to comment.