Skip to content

Commit

Permalink
[generate:entity:content] per-bundle-permissions (#4216)
Browse files Browse the repository at this point in the history
[generate:entity:content] wrongly creates one permission per entity (database row), instead of one permission per entity type.
  • Loading branch information
hudri authored Sep 15, 2022
1 parent 60c4cf9 commit 42e2dec
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Drupal\{{ module }};

{% block use_class %}
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\{{ module }}\Entity\{{ entity_class }};
use Drupal\{{ module }}\Entity\{{ entity_class }}Type;

{% endblock %}

Expand All @@ -37,7 +37,7 @@ class {{ entity_class }}Permissions{% endblock %}
public function generatePermissions() {
$perms = [];

foreach ({{ entity_class }}::loadMultiple() as $type) {
foreach ({{ entity_class }}Type::loadMultiple() as $type) {
$perms += $this->buildPermissions($type);
}

Expand All @@ -47,13 +47,13 @@ class {{ entity_class }}Permissions{% endblock %}
/**
* Returns a list of node permissions for a given node type.
*
* @param \Drupal\{{ module }}\Entity\{{ entity_class }} $type
* @param \Drupal\{{ module }}\Entity\{{ entity_class }}Type $type
* The {{ entity_class }} type.
*
* @return array
* An associative array of permission names and descriptions.
*/
protected function buildPermissions({{ entity_class}} $type) {
protected function buildPermissions({{ entity_class}}Type $type) {
$type_id = $type->id();
$type_params = ['%type_name' => $type->label()];

Expand Down

0 comments on commit 42e2dec

Please sign in to comment.