public function isPersisted(Identifier $identifier) { $key = $identifier->getId(); if (!isset($_SESSION[$this->namespace][$key])) { return false; } return true; }
/** * {@inheritDoc} */ public function processGetState(Identifier $identifier) { $state = null; try { //check if indexes exists every x times this method is called $this->checkAndCreateIndexesIfNecessary(500); //find the state //https://php.net/manual/en/mongocollection.findone.php $query = array("entity_id" => $identifier->getEntityId(), "machine" => $identifier->getMachine()); $data = $this->getClient()->izzum->states->findOne($query); if ($data) { $state = $data['state']; } } catch (\Exception $e) { throw new Exception(sprintf('getting current state failed: [%s]', $e->getMessage()), Exception::PERSISTENCE_LAYER_EXCEPTION); } if (!$state) { throw new Exception(sprintf('no state found for [%s]. Did you "$machine->add()" it to the persistence layer?', $identifier->getId(true)), Exception::PERSISTENCE_LAYER_EXCEPTION); } return $state; }
/** * {@inheritDoc} */ public function processGetState(Identifier $identifier) { $redis = $this->getRedis(); try { //get state from key $key = sprintf(self::KEY_ENTITY_STATE, $identifier->getMachine(), $identifier->getEntityId()); $state = $redis->get($key); } catch (\Exception $e) { throw new Exception(sprintf('getting current state failed: [%s]', $e->getMessage()), Exception::PERSISTENCE_LAYER_EXCEPTION); } if (!$state) { throw new Exception(sprintf('no state found for [%s]. ' . 'Did you "$machine->add()" it to the persistence layer?', $identifier->getId(true)), Exception::PERSISTENCE_LAYER_EXCEPTION); } return $state; }
public function getStorageFromRegistry(Identifier $identifier) { $registry = $this->getRegistry(); if (!isset($registry[$identifier->getId()])) { $storage = null; } else { $storage = $registry[$identifier->getId()]; } return $storage; }