/** * {@inheritDoc} */ public function processGetState(Identifier $identifier) { $connection = $this->getConnection(); $prefix = $this->getPrefix(); try { $query = 'SELECT state FROM ' . $prefix . 'statemachine_entities WHERE machine = ' . ':machine AND entity_id = :entity_id'; $machine = $identifier->getMachine(); $entity_id = $identifier->getEntityId(); $statement = $connection->prepare($query); $statement->bindParam(":machine", $machine); $statement->bindParam(":entity_id", $entity_id); $result = $statement->execute(); if ($result === false) { throw new Exception($this->getErrorInfo($statement)); } } catch (\Exception $e) { throw new Exception(sprintf('query for getting current state failed: [%s]', $e->getMessage()), Exception::PERSISTENCE_LAYER_EXCEPTION); } $row = $statement->fetch(); if ($row === false) { throw new Exception(sprintf('no state found for [%s]. Did you "$machine->add()" it to the persistence layer?', $identifier->toString()), Exception::PERSISTENCE_LAYER_EXCEPTION); return State::STATE_UNKNOWN; } return $row['state']; }