Comments

gabesullice created an issue. See original summary.

gabesullice’s picture

Status: Active » Needs review
StatusFileSize
new38.1 KB

Status: Needs review » Needs work

The last submitted patch, 2: 2987603-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gabesullice’s picture

Status: Needs work » Needs review
StatusFileSize
new37.97 KB
new594 bytes

Hopefully green :)

wim leers’s picture

Looks good!

+++ b/src/Controller/RequestHandler.php
@@ -116,7 +117,7 @@ class RequestHandler {
-    $parameters = [];
+    $parameters = ['resource_type' => $resource_type];
 
     $entity_type_id = $resource_type->getEntityTypeId();
     if ($entity = $request->get($entity_type_id)) {
@@ -129,7 +130,7 @@ class RequestHandler {

@@ -129,7 +130,7 @@ class RequestHandler {
 
     // Invoke the operation on the resource plugin.
     $action = $this->action($request, $resource_type);
-    $resource = $this->resourceFactory($resource_type);
+    $resource = $this->resourceFactory();
 
     // Only add the unserialized data if there is something there.
     $extra_parameters = $unserialized ? [$unserialized, $request] : [$request];
@@ -237,15 +238,11 @@ class RequestHandler {

@@ -237,15 +238,11 @@ class RequestHandler {
   /**
    * Get the resource.
    *
-   * @param \Drupal\jsonapi\ResourceType\ResourceType $resource_type
-   *   The JSON API resource type for the current request.
-   *
    * @return \Drupal\jsonapi\Controller\EntityResource
    *   The instantiated resource.
    */
-  protected function resourceFactory(ResourceType $resource_type) {
+  protected function resourceFactory() {
     $resource = new EntityResource(
-      $resource_type,
       $this->entityTypeManager,

This is the key change that enables all other refactoring.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

I wasn't sure yet what benefit this brought, but the next step's benefit is quite clear: #2987604-5: Turn EntityResource into a service.

  • gabesullice committed f0f4751 on 8.x-2.x
    Issue #2987603 by gabesullice, Wim Leers: Make resource type an explicit...
gabesullice’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.