You are here

public function EntityToJsonApi::__construct in JSON:API Extras 8.3

Same name and namespace in other branches
  1. 8.2 src/EntityToJsonApi.php \Drupal\jsonapi_extras\EntityToJsonApi::__construct()

EntityToJsonApi constructor.

Parameters

\Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel: The HTTP kernel.

\Drupal\jsonapi\ResourceType\ResourceTypeRepositoryInterface $resource_type_repository: The resource type repository.

\Symfony\Component\HttpFoundation\Session\SessionInterface $session: The session object.

\Symfony\Component\HttpFoundation\RequestStack $request_stack: The stack of requests.

File

src/EntityToJsonApi.php, line 62

Class

EntityToJsonApi
Simplifies the process of generating a JSON:API version of an entity.

Namespace

Drupal\jsonapi_extras

Code

public function __construct(HttpKernelInterface $http_kernel, ResourceTypeRepositoryInterface $resource_type_repository, SessionInterface $session, RequestStack $request_stack) {
  $this->httpKernel = $http_kernel;
  $this->resourceTypeRepository = $resource_type_repository;
  $this->currentRequest = $request_stack
    ->getCurrentRequest();
  $this->session = $this->currentRequest
    ->hasPreviousSession() ? $this->currentRequest
    ->getSession() : $session;
}