|
@@ -1,50 +0,0 @@
|
|
|
-<?php
|
|
|
-
|
|
|
-namespace FTTHBundle\Controller;
|
|
|
-
|
|
|
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
|
-use Symfony\Component\Workflow\Exception\ExceptionInterface;
|
|
|
-
|
|
|
-class ONUController extends Controller
|
|
|
-{
|
|
|
-
|
|
|
- public function applyTransitionAction(\FTTHBundle\Entity\ONU $onu, $transition, $workflow = null)
|
|
|
- {
|
|
|
- if(is_null($workflow)) {
|
|
|
- $workflow = "{$onu->getWorkflowType()}.{$onu->getWorkflow()}";
|
|
|
- }
|
|
|
-
|
|
|
- $em = $this->get('doctrine')->getManager();
|
|
|
- try {
|
|
|
- $this->get("{$workflow}")->apply($onu, $transition);
|
|
|
- $em->persist($onu);
|
|
|
- $em->flush();
|
|
|
- } catch (ExceptionInterface $e) {
|
|
|
- $this->get('session')->getFlashBag()->add('danger', $e->getMessage());
|
|
|
- }
|
|
|
-
|
|
|
- return $this->redirect($this->generateUrl('admin_ftth_onu_list'));
|
|
|
- }
|
|
|
-
|
|
|
- public function showWorkflowAction(\FTTHBundle\Entity\ONU $onu)
|
|
|
- {
|
|
|
- return $this->render('FTTHBundle:ONU:show_workflow.html.twig', ['onu' => $onu]);
|
|
|
- }
|
|
|
-
|
|
|
- public function resetStateAction(\FTTHBundle\Entity\ONU $onu)
|
|
|
- {
|
|
|
- $workflow = $onu->getWorkflowObject();
|
|
|
-
|
|
|
- if($workflow) {
|
|
|
- $onu->setCurrentState($workflow->getInitialPlace($onu));
|
|
|
- } else {
|
|
|
- $onu->setCurrentState(null);
|
|
|
- }
|
|
|
-
|
|
|
- $em = $this->get('doctrine')->getManager();
|
|
|
- $em->persist($onu);
|
|
|
- $em->flush();
|
|
|
-
|
|
|
- return $this->redirect($this->generateUrl('admin_ftth_onu_list'));
|
|
|
- }
|
|
|
-}
|