- Issue created by @lpeidro
- 🇪🇸Spain lpeidro Madrid
I have implemented the AccountInterface in a class named DummyAccount. This class allows us to instantiate account objects with a specific role, which we can use to test role-based access to entities. Currently, it only tests access for anonymous users, but in the future, we plan to expand its functionality to support different roles.
The access check to the entity is performed just before creating the source object for a given entity. Doing it at this point ensures that, in all contexts, only the entities accessible to the anonymous user will be processed.
I have implemented a unit test for this scenario.
It is ready to be checked by the comunnity.
- 🇪🇸Spain eduardo morales alberti Spain, 🇪🇺
Could you review the coding standard errors?
PHP CODE SNIFFER REPORT SUMMARY ---------------------------------------------------------------------- FILE ERRORS WARNINGS ---------------------------------------------------------------------- entity_mesh.libraries.yml 1 0 entity_mesh.permissions.yml 1 0 entity_mesh.routing.yml 1 0 src/DummyAccount.php 22 0 src/Repository.php 1 0 tests/src/Kernel/EntityMeshPermissionsTest.php 12 7 ---------------------------------------------------------------------- A TOTAL OF 38 ERRORS AND 7 WARNINGS WERE FOUND IN 60 FILES ---------------------------------------------------------------------- PHPCBF CAN FIX 43 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- PHP CODE SNIFFER VIOLATION SOURCE SUMMARY ---------------------------------------------------------------------- SOURCE COUNT ---------------------------------------------------------------------- [x] Drupal.Commenting.PostStatementComment.Found 15 [x] Drupal.Commenting.InlineComment.InvalidEndChar 14 [x] Drupal.Classes.UnusedUseStatement.UnusedUse 4 [x] Drupal.WhiteSpace.Comma.TooManySpaces 4 [x] Drupal.Arrays.Array.CommaLastItem 2 [x] Drupal.Files.EndFileNewline.TooMany 2 [x] Drupal.Commenting.DocComment.TagGroupSpacing 1 [ ] Drupal.Commenting.FunctionComment.MissingReturnComment 1 [x] Drupal.Files.EndFileNewline.NoneFound 1 [ ] Drupal.Files.LineLength.TooLong 1 ---------------------------------------------------------------------- A TOTAL OF 45 SNIFF VIOLATIONS WERE FOUND IN 10 SOURCES ---------------------------------------------------------------------- PHPCBF CAN FIX THE 8 MARKED SOURCES AUTOMATICALLY (43 VIOLATIONS IN TOTAL) ----------------------------------------------------------------------
- 🇪🇸Spain Juanjol Navarra
Thanks for the MR! The implementation looks good.
Two minor suggestions :
- Consider renaming DummyAccount to AnonymousDummyAccount for clarity
- Maybe use dependency injection instead of the static variable in Repository::checkAccessEntity() to follow Drupal best practices
- 🇪🇸Spain Juanjol Navarra
Please take a look too to the phpcs in the pipeline https://git.drupalcode.org/project/entity_mesh/-/jobs/5876370