You are here

public function EntityToJsonApi::__construct in JSON:API 8

EntityToJsonApi constructor.

Parameters

\Drupal\jsonapi\Serializer\Serializer $serializer: The serializer.

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

\Drupal\Core\Session\AccountInterface $current_user: The currently logged in user.

\Symfony\Component\HttpFoundation\RequestStack $request_stack: The request stack.

string $jsonapi_base_path: The JSON API base path.

File

src/EntityToJsonApi.php, line 69

Class

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

Namespace

Drupal\jsonapi

Code

public function __construct(Serializer $serializer, ResourceTypeRepositoryInterface $resource_type_repository, AccountInterface $current_user, RequestStack $request_stack, $jsonapi_base_path) {
  $this->serializer = $serializer;
  $this->resourceTypeRepository = $resource_type_repository;
  $this->currentUser = $current_user;
  $this->requestStack = $request_stack;
  assert(is_string($jsonapi_base_path));
  assert($jsonapi_base_path[0] === '/');
  assert(substr($jsonapi_base_path, -1) !== '/');
  $this->jsonApiBasePath = $jsonapi_base_path;
}