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

@clemens-tolboom clemens-tolboom 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 Add has-bundle-permission for generate:entity:content. 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
Copy link
Contributor Author

Travis could not fetch composer ... tsss

@enzolutions
Copy link
Contributor

Thanks @clemens-tolboom

@enzolutions enzolutions merged commit 3c83f02 into hechoendrupal:master Sep 6, 2019
enzolutions pushed a commit that referenced this pull request Oct 10, 2019
* Update services.yml

* Fix Travis tests

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* 1

* Ensure $roles is an array when creating users. (#4134)

This prevents an error from being thrown when constructing the success message.  See #4133.

* Generate revisional entity content is broken (#4139)

* Add bundle permissions for content entity (#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 #4139 as it hurts.

* Add own permissions checks.

* Add --default option to database:add (#4143)

This option allows to set the database as the default one instead of
adding a new database in addition to the default one.

See: #4142

* Update version to 1.9.3 (#4144)

* Update version to 1.9.3

* Remove Module/InstallCommand::moduleRequirement

* Remove
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants