/**
  * @param StatefulInterface $object
  * @return TokenReadInterface[]
  */
 public function getTokens(StatefulInterface $object)
 {
     $request = $this->stack->getCurrentRequest();
     $process = $request->attributes->get($this->processPath, null, true);
     $stateMachine = $this->factory->create($process, $object);
     return $stateMachine->getTokens();
 }
예제 #2
0
 /**
  * @inheritdoc
  */
 public function handle(Request $request, StatefulInterface $object)
 {
     $process = $request->attributes->get($this->processPath, null, true);
     $action = $request->attributes->get($this->actionPath, null, true);
     $stateMachine = $this->factory->create($process, $object);
     if (!$stateMachine->hasToken($action)) {
         throw new HttpException(404, 'Action not found');
     }
     $response = $stateMachine->applyToken($action, $request);
     if (null === $response) {
         $response = $this->prepareResponse($request);
     }
     return $response;
 }