Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ services:
public: true
arguments:
- '@workflow.registry'
- workflow_name: pull_request
- render_actions: [show]
workflow_name: pull_request
no_transition_label: No transition for pull request
no_transition_icon: fa fa-times
dropdown_transitions_label: Pull request transitions
Expand All @@ -155,6 +156,7 @@ sonata_admin:

What are these options ?

- `render_actions` : Admin action names on which the extension should render its menu (defaults to `[show, edit]`)
- `workflow_name` : The name of the Workflow to handle (defaults to `null`)
- `no_transition_display` : Whether or not to display a button when no transition is enabled (defaults to `false`)
- `no_transition_label` : The button label when no transition is enabled (defaults to `workflow_transitions_empty`)
Expand Down
6 changes: 6 additions & 0 deletions src/Admin/Extension/WorkflowExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public function configureSideMenu(
$action,
AdminInterface $childAdmin = null
) {
if (!in_array($action, $this->options['render_actions'], true)) {
return;
}

$subject = $admin->getSubject();
if (null === $subject) {
return;
Expand Down Expand Up @@ -111,6 +115,7 @@ protected function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefaults([
'render_actions' => ['edit', 'show'],
'workflow_name' => null,
'no_transition_display' => false,
'no_transition_label' => 'workflow_transitions_empty',
Expand All @@ -120,6 +125,7 @@ protected function configureOptions(OptionsResolver $resolver)
'transitions_default_icon' => null,
'transitions_icons' => [],
])
->setAllowedTypes('render_actions', ['string[]'])
->setAllowedTypes('workflow_name', ['string', 'null'])
->setAllowedTypes('no_transition_display', ['bool'])
->setAllowedTypes('no_transition_label', ['string'])
Expand Down