/**
  * Create the hash for a metamodel item.
  *
  * @param GetHashEvent $event The get hash event.
  *
  * @return void
  */
 public function getItemHash(GetHashEvent $event)
 {
     $data = $event->getData();
     if ($data instanceof IItem) {
         $hash = sprintf('%s_%s', $data->getMetaModel()->getTableName(), $data->get('id'));
         $event->setHash($hash);
     }
 }
예제 #2
0
 /**
  * Get hash fallback if no hash was created so far.
  *
  * @param GetHashEvent $event The subscribed event.
  *
  * @return void
  */
 public function getFallback(GetHashEvent $event)
 {
     if ($event->getHash()) {
         return;
     }
     $data = $event->getData();
     if (is_object($data)) {
         $event->setHash(spl_object_hash($data));
     } else {
         $event->setHash(md5(json_encode($data)));
     }
 }