Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bundle permissions for content entity #4138

Conversation

@clemens-tolboom
Copy link
Contributor

commented Aug 22, 2019

PR for #3498

Description

This patch generates bundle specific permissions related to CRUD with implementation and sets up permissions for revisioning but does not implement the checks as I did not see revisions in the UI.

Tasks

(still little sketchy)

  • Add switch --permission_granularity [bundle|entity_type] to command chain for EntityContentGenerator
  • Adjust templates/module/src/accesscontrolhandler-entity-content.php.twig to generate fine grained permissions
  • Add permission_granularity to templates/module/src/Entity/entity-content.php.twig
  • vendor/drupal/console/templates/module/src/Controller/entity-controller.php.twig
  • Something similar to \Drupal\node\NodePermissions for when creating a new entityType it's permissions are made available too.
  • this is called from core/modules/node/node.permissions.yml:27 permission_callbacks
  • PR hechoendrupal/drupal-console-en#250 Add translations to console-en

Testing

This depends on PR #4139 for revisionable.

Remove generated module

# delete module
rm -r modules/custom/test_changes

# Generate module
vendor/bin/drupal \
  --no-interaction \
  generate:module  \
  --module="Test changes"  \
  --machine-name="test_changes"  \
  --module-path="modules/custom"  \
  --description="Test changes done on drupal/console"  \
  --core="8.x"  \
  --package="Other"  \
  --dependencies="" \
  --module-file  \
  --test

# Generate Entity
vendor/bin/drupal \
  --no-interaction \
  generate:entity:content  \
  --module="test_changes"  \
  --entity-class="TestChanges"  \
  --entity-name="test_changes"  \
  --base-path="/admin/content"  \
  --label="Test Changes"  \
  --is-translatable \
  --revisionable \
  --has-forms \
  --has-bundles \
  --has-owner \
  --has-bundle-permissions

# Code sane?
drush cache-rebuild

# Enable
drush pm:enable test_changes

Visit affected pages

# Uninstall
drush pm:uninstall test_changes

@clemens-tolboom clemens-tolboom changed the title WIP: Add bundle permissions for content entity Add bundle permissions for content entity Aug 24, 2019

@clemens-tolboom

This comment has been minimized.

Copy link
Contributor Author

commented Aug 24, 2019

Travis could not fetch composer ... tsss

@enzolutions

This comment has been minimized.

Copy link
Contributor

commented Sep 6, 2019

@enzolutions enzolutions merged commit 3c83f02 into hechoendrupal:master Sep 6, 2019

1 check failed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
mondrake added a commit to mondrake/drupal-console that referenced this pull request Sep 8, 2019
Add bundle permissions for content entity (hechoendrupal#4138)
* Add command option has-bundle-permissions and use on entity.

* Add (Entity}Permissions.php file.

* Add permission_callback to permissions.yml file.

* Added fix from hechoendrupal#4139 as it hurts.

* Add own permissions checks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.