only in patch2: unchanged: --- a/src/Controller/EntityResource.php +++ b/src/Controller/EntityResource.php @@ -15,7 +15,6 @@ use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\EntityReferenceFieldItemListInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; -use Drupal\jsonapi\Context\CurrentContext; use Drupal\jsonapi\Exception\EntityAccessDeniedHttpException; use Drupal\jsonapi\Exception\UnprocessableHttpEntityException; use Drupal\jsonapi\Query\Filter; @@ -59,13 +58,6 @@ class EntityResource { */ protected $fieldManager; - /** - * The current context service. - * - * @var \Drupal\jsonapi\Context\CurrentContext - */ - protected $currentContext; - /** * The current context service. * @@ -89,18 +81,15 @@ class EntityResource { * The entity type manager. * @param \Drupal\Core\Entity\EntityFieldManagerInterface $field_manager * The entity type field manager. - * @param \Drupal\jsonapi\Context\CurrentContext $current_context - * The current context. * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $plugin_manager * The plugin manager for fields. * @param \Drupal\jsonapi\LinkManager\LinkManager $link_manager * The link manager service. */ - public function __construct(ResourceType $resource_type, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $field_manager, CurrentContext $current_context, FieldTypePluginManagerInterface $plugin_manager, LinkManager $link_manager) { + public function __construct(ResourceType $resource_type, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $field_manager, FieldTypePluginManagerInterface $plugin_manager, LinkManager $link_manager) { $this->resourceType = $resource_type; $this->entityTypeManager = $entity_type_manager; $this->fieldManager = $field_manager; - $this->currentContext = $current_context; $this->pluginManager = $plugin_manager; $this->linkManager = $link_manager; } only in patch2: unchanged: --- a/src/Controller/RequestHandler.php +++ b/src/Controller/RequestHandler.php @@ -74,7 +74,7 @@ class RequestHandler implements ContainerAwareInterface, ContainerInjectionInter // Invoke the operation on the resource plugin. $action = $this->action($route_match, $method); - $resource = $this->resourceFactory($route, $current_context); + $resource = $this->resourceFactory($route); // Only add the unserialized data if there is something there. $extra_parameters = $unserialized ? [$unserialized, $request] : [$request]; @@ -184,13 +184,11 @@ class RequestHandler implements ContainerAwareInterface, ContainerInjectionInter * * @param \Symfony\Component\Routing\Route $route * The matched route. - * @param \Drupal\jsonapi\Context\CurrentContext $current_context - * The current context. * * @return \Drupal\jsonapi\Controller\EntityResource * The instantiated resource. */ - protected function resourceFactory(Route $route, CurrentContext $current_context) { + protected function resourceFactory(Route $route) { /** @var \Drupal\jsonapi\ResourceType\ResourceTypeRepositoryInterface $resource_type_repository */ $resource_type_repository = $this->container->get('jsonapi.resource_type.repository'); /* @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */ @@ -205,7 +203,6 @@ class RequestHandler implements ContainerAwareInterface, ContainerInjectionInter $resource_type_repository->get($route->getRequirement('_entity_type'), $route->getRequirement('_bundle')), $entity_type_manager, $field_manager, - $current_context, $plugin_manager, $link_manager ); only in patch2: unchanged: --- a/tests/src/Kernel/Controller/EntityResourceTest.php +++ b/tests/src/Kernel/Controller/EntityResourceTest.php @@ -7,7 +7,6 @@ use Drupal\Core\Field\EntityReferenceFieldItemListInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Routing\CurrentRouteMatch; use Drupal\jsonapi\ResourceType\ResourceType; -use Drupal\jsonapi\Context\CurrentContext; use Drupal\jsonapi\Controller\EntityResource; use Drupal\jsonapi\Resource\EntityCollection; use Drupal\jsonapi\Resource\JsonApiDocumentTopLevel; @@ -230,19 +229,12 @@ class EntityResourceTest extends JsonapiKernelTestBase { ]); $request_stack = new RequestStack(); $request_stack->push($request); - // Get the entity resource. - $current_context = new CurrentContext( - $this->container->get('jsonapi.resource_type.repository'), - $request_stack, - new CurrentRouteMatch($request_stack) - ); - $this->container->set('jsonapi.current_context', $current_context); + // Get the entity resource. $entity_resource = new EntityResource( $this->container->get('jsonapi.resource_type.repository')->get('node_type', 'node_type'), $this->container->get('entity_type.manager'), $field_manager, - $current_context, $this->container->get('plugin.manager.field.field_type'), $this->container->get('jsonapi.link_manager') ); @@ -283,19 +275,12 @@ class EntityResourceTest extends JsonapiKernelTestBase { ]); $request_stack = new RequestStack(); $request_stack->push($request); - // Get the entity resource. - $current_context = new CurrentContext( - $this->container->get('jsonapi.resource_type.repository'), - $request_stack, - new CurrentRouteMatch($request_stack) - ); - $this->container->set('jsonapi.current_context', $current_context); + // Get the entity resource. $entity_resource = new EntityResource( $this->container->get('jsonapi.resource_type.repository')->get('node_type', 'node_type'), $this->container->get('entity_type.manager'), $field_manager, - $current_context, $this->container->get('plugin.manager.field.field_type'), $this->container->get('jsonapi.link_manager') ); @@ -337,19 +322,12 @@ class EntityResourceTest extends JsonapiKernelTestBase { ]); $request_stack = new RequestStack(); $request_stack->push($request); - // Get the entity resource. - $current_context = new CurrentContext( - $this->container->get('jsonapi.resource_type.repository'), - $request_stack, - new CurrentRouteMatch($request_stack) - ); - $this->container->set('jsonapi.current_context', $current_context); + // Get the entity resource. $entity_resource = new EntityResource( $this->container->get('jsonapi.resource_type.repository')->get('node', 'article'), $this->container->get('entity_type.manager'), $field_manager, - $current_context, $this->container->get('plugin.manager.field.field_type'), $this->container->get('jsonapi.link_manager') ); @@ -859,19 +837,12 @@ class EntityResourceTest extends JsonapiKernelTestBase { $request = new Request([], [], ['_route_object' => $route]); $request_stack = new RequestStack(); $request_stack->push($request); - // Get the entity resource. - $current_context = new CurrentContext( - $this->container->get('jsonapi.resource_type.repository'), - $request_stack, - new CurrentRouteMatch($request_stack) - ); - $this->container->set('jsonapi.current_context', $current_context); + // Get the entity resource. return new EntityResource( new ResourceType($entity_type_id, $bundle, NULL), $this->container->get('entity_type.manager'), $this->container->get('entity_field.manager'), - $current_context, $this->container->get('plugin.manager.field.field_type'), $this->container->get('jsonapi.link_manager') );