Skip to content

Commit 9b5e8ac

Browse files
nequetemeenzolutions
authored andcommitted
[generate:entity:content] permissions for no-bundle entity (#4181)
validate if the entity have bundles it's on true and create permissions
1 parent b21607f commit 9b5e8ac

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/Command/Generate/EntityContentCommand.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,16 @@ protected function interact(InputInterface $input, OutputInterface $output)
167167
$input->setOption('has-owner', $has_owner);
168168

169169
// --has-bundle-permissions
170-
$has_bundle_permissions = $this->getIo()->confirm(
170+
if($bundle_of){
171+
$has_bundle_permissions = $this->getIo()->confirm(
171172
$this->trans('commands.generate.entity.content.questions.has-bundle-permissions'),
172173
true
173-
);
174-
$input->setOption('has-bundle-permissions', $has_bundle_permissions);
174+
);
175+
$input->setOption('has-bundle-permissions', $has_bundle_permissions);
176+
}
177+
else {
178+
$input->setOption('has-bundle-permissions', false);
179+
}
175180
}
176181

177182
/**

src/Generator/EntityContentGenerator.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,6 @@ public function generate(array $parameters)
8383
FILE_APPEND
8484
);
8585

86-
if ($has_bundle_permissions) {
87-
$this->renderFile(
88-
'module/src/entity-content-bundle-permissions.php.twig',
89-
$moduleSourcePath . 'Permissions.php',
90-
$parameters
91-
);
92-
}
93-
9486
$this->renderFile(
9587
'module/src/accesscontrolhandler-entity-content.php.twig',
9688
$moduleSourcePath . 'AccessControlHandler.php',
@@ -232,12 +224,21 @@ public function generate(array $parameters)
232224
}
233225

234226
if ($bundle_entity_type) {
227+
235228
$this->renderFile(
236229
'module/templates/entity-with-bundle-content-add-list-html.twig',
237230
$moduleTemplatePath . '/' . str_replace('_', '-', $entity_name) . '-content-add-list.html.twig',
238231
$parameters
239232
);
240233

234+
if ($has_bundle_permissions) {
235+
$this->renderFile(
236+
'module/src/entity-content-bundle-permissions.php.twig',
237+
$moduleSourcePath . 'Permissions.php',
238+
$parameters
239+
);
240+
}
241+
241242
// Check for hook_theme() in module file and warn ...
242243
// Check if the module file exists.
243244
if (!file_exists($moduleFileName)) {

0 commit comments

Comments
 (0)