Skip to content

Commit

Permalink
Issue #3115772 by saurabh.rocksoul, swatichouhan012, Wim Leers, alexp…
Browse files Browse the repository at this point in the history
…ott: User::load calls should be avoided in classes, use dependency injection instead in jsonapi module

(cherry picked from commit 8b7aee5be46a7218bcb5563069c0cf9bea75b82c)
  • Loading branch information
xjm committed May 3, 2020
1 parent e26a568 commit a86b5c8
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions modules/jsonapi/src/Controller/EntryPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Drupal\jsonapi\ResourceResponse;
use Drupal\jsonapi\ResourceType\ResourceType;
use Drupal\jsonapi\ResourceType\ResourceTypeRepositoryInterface;
use Drupal\user\Entity\User;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Exception\RouteNotFoundException;

Expand Down Expand Up @@ -104,7 +103,7 @@ public function index() {

$meta = [];
if ($this->user->isAuthenticated()) {
$current_user_uuid = User::load($this->user->id())->uuid();
$current_user_uuid = $this->entityTypeManager()->getStorage('user')->load($this->user->id())->uuid();
$meta['links']['me'] = ['meta' => ['id' => $current_user_uuid]];
$cacheability->addCacheContexts(['user']);
try {
Expand Down

0 comments on commit a86b5c8

Please sign in to comment.