123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <?php
- namespace WorkflowBundle\Entity\Traits;
- trait WorkflowTrait
- {
- /**
- * @return Workflow
- */
- public function getWorkflow()
- {
- return $this->workflow;
- }
- /**
- * @param Workflow $workflow
- *
- * @return $this
- */
- public function setWorkflow($workflow)
- {
- $this->workflow = $workflow;
- return $this;
- }
- /**
- * @return string
- */
- public function getCurrentState()
- {
- return $this->currentState;
- }
- /**
- * @param string $currentState
- *
- * @return WorkflowInterface
- */
- public function setCurrentState($currentState)
- {
- $this->currentState = $currentState;
- return $this;
- }
- /**
- * @return string
- */
- public function getTransitionState()
- {
- return $this->transitionState;
- }
- /**
- * @param string $transitionState
- *
- * @return WorkflowInterface
- */
- public function setTransitionState($transitionState)
- {
- $this->transitionState = $transitionState;
- return $this;
- }
- /**
- * Retorna el administrativeState en caso que exista en la entidad
- *
- * @return string
- */
- public function getAdministrativeState()
- {
- return property_exists(self::class, 'administrativeState') ? $this->administrativeState : null;
- }
- /**
- * Setea el administrativeState en caso que exista en la entidad
- *
- * @param string $transitionState
- *
- * @return WorkflowInterface
- */
- public function setAdministrativeState($administrativeState)
- {
- if (property_exists(self::class, 'administrativeState')) {
- $this->administrativeState = $administrativeState;
- }
- return $this;
- }
- /**
- * @return string
- */
- public function getTransitionWorkflow()
- {
- return "transition_state";
- }
- /**
- * @return null|string
- */
- public function getWorkflowType()
- {
- $workflow = $this->getWorkflow();
- if ($workflow) {
- return $workflow->getType();
- }
- return null;
- }
- /**
- * @return null|string
- */
- public function getWorkflowName()
- {
- $workflow = $this->getWorkflow();
- if ($workflow) {
- return $workflow->getName();
- }
- return null;
- }
- /**
- * Para coincider entre estos workflow servidos por servicio y aquellos levantados por ABM
- *
- * @global AppKernel $kernel
- *
- * @return Workflow
- */
- public function getServiceWorkflow()
- {
- global $kernel;
- $registry = $kernel->getContainer()->get('workflow.registry');
- $workflow_name = null;
- $workflow = $this->getWorkflow();
- if ($workflow) {
- $workflow_name = $workflow->getName();
- }
- try {
- $workflow = $registry->get($this, $workflow_name);
- } catch (ExceptionInterface $e) {
- $kernel->getContainer()->get('session')->getFlashBag()->add('danger', $kernel->getContainer()->get('translator')->trans('Incorrect Workflow', array(), 'FTTHBundle'));
- return null;
- }
- return $workflow;
- }
- }
|