getId() публичный Метод

get the unique identifier representation for an Identifier, which consists of the machine name and the entity_id in parseable form.
public getId ( boolean $readable = false ) : string
$readable boolean human readable or not. defaults to false
Результат string
Пример #1
0
 public function isPersisted(Identifier $identifier)
 {
     $key = $identifier->getId();
     if (!isset($_SESSION[$this->namespace][$key])) {
         return false;
     }
     return true;
 }
Пример #2
0
 /**
  * {@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;
 }