|
@@ -13,6 +13,12 @@ class WorkflowBaseAdmin extends BaseAdmin
|
|
|
public function getBatchActions()
|
|
|
{
|
|
|
$actions = parent::getBatchActions();
|
|
|
+ $tmp = $actions;
|
|
|
+ $actions = [];
|
|
|
+ $actions['Default'] = array(
|
|
|
+ 'label' => $this->trans('Default', array(), 'WorkflowLabel'),
|
|
|
+ 'group' => $tmp
|
|
|
+ );
|
|
|
|
|
|
$workflows = array();
|
|
|
$registry = $this->get('workflow.registry');
|
|
@@ -25,24 +31,30 @@ class WorkflowBaseAdmin extends BaseAdmin
|
|
|
$workflows[] = $registry->get($tmpEntity);
|
|
|
}
|
|
|
} catch (\Exception $ex) {
|
|
|
- // No hay workflows en db, pruebo traer desde el workflow registry
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($this->batchWorkflows)) {
|
|
|
+ // No hay workflows en db, pruebo traer desde el workflow registry
|
|
|
// con los names definidos en el admin $batchWorkflows
|
|
|
- if (isset($this->batchWorkflows)) {
|
|
|
- foreach ($this->batchWorkflows as $name) {
|
|
|
- $workflows[] = $registry->get($tmpEntity, $name);
|
|
|
- }
|
|
|
+ foreach ($this->batchWorkflows as $name) {
|
|
|
+ $workflows[] = $registry->get($tmpEntity, $name);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
foreach ($workflows as $workflow) {
|
|
|
- $definition = method_exists($workflow, 'getSubject')
|
|
|
- ? $workflow->getDefinition($workflow->getSubject())
|
|
|
- : $workflow->getDefinition();
|
|
|
+ $definition = method_exists($workflow, 'getSubject')
|
|
|
+ ? $workflow->getDefinition($workflow->getSubject())
|
|
|
+ : $workflow->getDefinition();
|
|
|
$transitions = $definition ? $definition->getTransitions() : array();
|
|
|
+ $tmp = array();
|
|
|
foreach ($transitions as $transition) {
|
|
|
- $label = $this->trans('workflow.' . $workflow->getName() . '.transitions.' . $transition->getName(), array(), 'WorkflowLabel');
|
|
|
+ $id = 'workflow.' . $workflow->getName() . '.transitions.' . $transition->getName();
|
|
|
+ $label = $this->trans($id, array(), 'WorkflowLabel');
|
|
|
+ if ($label == $id) {
|
|
|
+ $label = $transition->getName();
|
|
|
+ }
|
|
|
$label .= " ( {$transition->getName()} )";
|
|
|
- $actions[$transition->getName()] = array(
|
|
|
+ $tmp[$transition->getName()] = array(
|
|
|
'label' => $label,
|
|
|
'ask_confirmation' => true,
|
|
|
'workflow' => array(
|
|
@@ -51,10 +63,11 @@ class WorkflowBaseAdmin extends BaseAdmin
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
+ $actions[$workflow->getName()] = array(
|
|
|
+ 'label' => $this->trans($workflow->getName(), array(), 'WorkflowLabel'),
|
|
|
+ 'group' => $tmp
|
|
|
+ );
|
|
|
}
|
|
|
- asort($actions);
|
|
|
-
|
|
|
return $actions;
|
|
|
}
|
|
|
-
|
|
|
}
|