Skip to content

Commit

Permalink
[generate:entity:content] permissions for no-bundle entity (#4181)
Browse files Browse the repository at this point in the history
validate if the entity have bundles it's on true and create permissions
  • Loading branch information
nequeteme authored and enzolutions committed Oct 23, 2019
1 parent b21607f commit 9b5e8ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
11 changes: 8 additions & 3 deletions src/Command/Generate/EntityContentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,16 @@ protected function interact(InputInterface $input, OutputInterface $output)
$input->setOption('has-owner', $has_owner);

// --has-bundle-permissions
$has_bundle_permissions = $this->getIo()->confirm(
if($bundle_of){
$has_bundle_permissions = $this->getIo()->confirm(
$this->trans('commands.generate.entity.content.questions.has-bundle-permissions'),
true
);
$input->setOption('has-bundle-permissions', $has_bundle_permissions);
);
$input->setOption('has-bundle-permissions', $has_bundle_permissions);
}
else {
$input->setOption('has-bundle-permissions', false);
}
}

/**
Expand Down
17 changes: 9 additions & 8 deletions src/Generator/EntityContentGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ public function generate(array $parameters)
FILE_APPEND
);

if ($has_bundle_permissions) {
$this->renderFile(
'module/src/entity-content-bundle-permissions.php.twig',
$moduleSourcePath . 'Permissions.php',
$parameters
);
}

$this->renderFile(
'module/src/accesscontrolhandler-entity-content.php.twig',
$moduleSourcePath . 'AccessControlHandler.php',
Expand Down Expand Up @@ -232,12 +224,21 @@ public function generate(array $parameters)
}

if ($bundle_entity_type) {

$this->renderFile(
'module/templates/entity-with-bundle-content-add-list-html.twig',
$moduleTemplatePath . '/' . str_replace('_', '-', $entity_name) . '-content-add-list.html.twig',
$parameters
);

if ($has_bundle_permissions) {
$this->renderFile(
'module/src/entity-content-bundle-permissions.php.twig',
$moduleSourcePath . 'Permissions.php',
$parameters
);
}

// Check for hook_theme() in module file and warn ...
// Check if the module file exists.
if (!file_exists($moduleFileName)) {
Expand Down

0 comments on commit 9b5e8ac

Please sign in to comment.