get('workflow.registry'); $class = $this->getClass(); $tmpEntity = new $class(); try { $workflows = $this->getRepository('WorkflowBundle:Workflow')->findAllByClass($this->getClass()); // No hay workflows en db, pruebo traer desde el workflow registry if (count($workflows) == 0) { $workflows[] = $registry->get($tmpEntity); } } catch (\Exception $ex) { // 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 ($workflows as $workflow) { $definition = method_exists($workflow, 'getSubject') ? $workflow->getDefinition($workflow->getSubject()) : $workflow->getDefinition(); $transitions = $definition ? $definition->getTransitions() : array(); foreach ($transitions as $transition) { $label = $this->trans('workflow.' . $workflow->getName() . '.transitions.' . $transition->getName(), array(), 'WorkflowLabel'); $label .= " ( {$transition->getName()} )"; $actions[$transition->getName()] = array( 'label' => $label, 'ask_confirmation' => true, 'workflow' => array( 'name' => $workflow->getName(), 'transition' => $transition->getName(), ), ); } } asort($actions); return $actions; } }