Provides plugins that can operate above the default core REST resource plugins specifically for entities. By this allows you to easily serve and create your entities the way that you want.

For the complete readme and list of features see the page of the module. Also you can find an example plugin in the repository README file.

Clone command:
git clone --branch 8.x-1.x https://git.drupal.org/project/entity_resource_layer.git

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

_Archy_ created an issue. See original summary.

Mario Steinitz’s picture

Issue summary: View changes
Status: Needs review » Needs work

Git errors:

Review of the 8.x-1.x branch (commit 2751bb3):

  • Your README.md does not follow best practices (headings need to be uppercase). See https://www.drupal.org/node/2181737 .
    • The INTRODUCTION section is missing.
    • The REQUIREMENTS section is missing.
    • The INSTALLATION section is missing.
    • The CONFIGURATION section is missing.
  • Remove the LICENSE, drupal.org packaging will add a LICENSE.txt file automatically.
  • The entity_resource_layer.module does not implement hook_help(). See https://www.drupal.org/docs/develop/documenting-your-project/module-docu... .
  • Coder Sniffer has found some issues with your code (please check the Drupal coding standards).
    
    FILE: ./src/EntityResourceLayerBase.php
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------
     9 | WARNING | [x] Unused use statement
    --------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------
    
    
    FILE: ./src/Exception/EntityResourceFieldException.php
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------
     59 | WARNING | [x] A comma should follow the last multiline array item.
        |         |     Found: )
    --------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------
    
    
    FILE: ./src/Exception/EntityResourceConstraintException.php
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    --------------------------------------------------------------------------
     23 | WARNING | [x] A comma should follow the last multiline array item.
        |         |     Found: ]
     39 | WARNING | [x] A comma should follow the last multiline array item.
        |         |     Found: ]
    --------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------
    
    
    FILE: ./src/EventSubscriber/ExceptionJsonSubscriber.php
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------
     7 | WARNING | [x] Unused use statement
    --------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------
    
    
    FILE: ./src/Resource/EntityResource.php
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------
     109 | WARNING | [x] A comma should follow the last multiline array item.
         |         |     Found: ]
    --------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------
    
    
    FILE: ./src/Normalizer/EntityAdaptorNormalizer.php
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    --------------------------------------------------------------------------
      5 | WARNING | [x] Unused use statement
     11 | WARNING | [x] Unused use statement
    --------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------
    
    
    FILE: ./README.md
    --------------------------------------------------------------------------
    FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
    --------------------------------------------------------------------------
      11 | WARNING | [ ] Line exceeds 80 characters; contains 110 characters
      77 | WARNING | [ ] Line exceeds 80 characters; contains 83 characters
      84 | ERROR   | [x] There must be one blank line after the namespace
         |         |     declaration
     175 | ERROR   | [x] Whitespace found at end of line
    --------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------
    
    Time: 1.19 secs; Memory: 8Mb
    
  • DrupalPractice has found some issues with your code, but could be false positives.
    
    FILE: ./src/ParamConverter/EntityBundleConverter.php
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    --------------------------------------------------------------------------
      69 | WARNING | \Drupal calls should be avoided in classes, use
         |         | dependency injection instead
     133 | WARNING | Variable $entity_type_slug is undefined.
    --------------------------------------------------------------------------
    
    
    FILE: ./src/Normalizer/EntityAdaptorNormalizer.php
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    --------------------------------------------------------------------------
     135 | WARNING | \Drupal calls should be avoided in classes, use
         |         | dependency injection instead
     152 | WARNING | \Drupal calls should be avoided in classes, use
         |         | dependency injection instead
    --------------------------------------------------------------------------
    
    
    FILE: ./entity_resource_layer.info.yml
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------
     7 | WARNING | All dependencies must be prefixed with the project name,
       |         | for example "drupal:"
    --------------------------------------------------------------------------
    
    Time: 610ms; Memory: 6Mb
    
  • No automated test cases were found, did you consider writing PHPUnit tests? This is not a requirement but encouraged for professional software development.
bharath-kondeti’s picture

Status: Needs work » Needs review
FileSize
12.15 KB

Hi,

I have fixed the code sniffer errors and warnings. Please review the patch attached.

_Archy_’s picture

Status: Needs review » Needs work

Thanks for the patch. Only a couple of notices:

  1. entity_resource_layer.normalizer.entity_adaptor:
         class: Drupal\entity_resource_layer\Normalizer\EntityAdaptorNormalizer
    -    arguments: ['@entity.manager', '@request_stack', '@plugin.manager.entity_resource_layer']
    +    arguments: ['@entity.manager', '@request_stack', '@plugin.manager.entity_resource_layer', '@entity_field.manager', '@logger.factory']
         tags:
           - { name: normalizer, priority: 110 }

    Let's use @logger.factory.rest

  2. // If the entity type is dynamic, it will be pulled from the route defaults.
    +    $entity_type_slug = '';
         if (strpos($typeString, '{') === 0) {
           $entityTypeSlug = substr($typeString, 1, -1);

    We don't have to declare a new variable. There is already one but with camel case typing.

_Archy_’s picture

Status: Needs work » Needs review
FileSize
39.83 KB
35.75 KB

Addressed all the problems described in #2. Test I will add if the module gets used / developed.

_Archy_’s picture

Wrong headings in readme.

Mario Steinitz’s picture

Status: Needs review » Needs work

Better apply your changes directly to the development version of your module. This eases testing and ensures the repo is up-to-date with the fixes. (As it is the repo that will be reviewed, not your repo plus patches that might come somewhen later.)

_Archy_’s picture

Status: Needs work » Needs review

Updated development branch with above patch. I guess I will create a new release once everything is ok.

bharath-kondeti’s picture

Can you please provide me a credit for the patch

_Archy_’s picture

Weird I copied the commit from crediting and added you as-well. Not sure why it didn't link with you.
Check https://www.drupal.org/node/2940946/commits

sleitner’s picture

Status: Needs review » Closed (outdated)

Stable releases for this project are already covered by the security advisory policy.