public function isPersisted(Identifier $identifier)
{
$connection = $this->getConnection();
$prefix = $this->getPrefix();
try {
$query = 'SELECT entity_id FROM ' . $prefix . 'statemachine_entities WHERE ' . 'machine = :machine AND entity_id = :entity_id';
$statement = $connection->prepare($query);
$machine = $identifier->getMachine();
$entity_id = $identifier->getEntityId();
$statement->bindParam(":machine", $machine);
$statement->bindParam(":entity_id", $entity_id);
$result = $statement->execute();
if ($result === false) {
throw new Exception($this->getErrorInfo($statement));
}
$row = $statement->fetch();
if ($row === false) {
return false;
}
return $row['entity_id'] == $identifier->getEntityId();
} catch (\Exception $e) {
throw new Exception(sprintf('query for getting persistence info failed: [%s]', $e->getMessage()), Exception::PERSISTENCE_LAYER_EXCEPTION);
}
}