Ejemplo n.º 1
0
 /**
  * Occurs on classcontent.onflush events.
  *
  * @param Event $event
  */
 public static function onPostLoad(Event $event)
 {
     $revision = $event->getTarget();
     $dispatcher = $event->getDispatcher();
     $application = $dispatcher->getApplication();
     if (null !== $application) {
         $em = $application->getEntityManager();
         $revision->setEntityManager($em)->setToken($application->getBBUserToken());
         if (null === $revision->getContent()) {
             $db = $em->getConnection();
             $stmt = $db->executeQuery('SELECT `content_uid`, `classname` FROM `revision` WHERE `uid` = ?', [$revision->getUid()]);
             $items = $stmt->fetchAll();
             if ($items) {
                 foreach ($items as $item) {
                     $content = $em->find(Revision::getFullClassname($item['classname']), $item['content_uid']);
                     if ($content) {
                         $revision->setContent($content);
                     }
                 }
             }
         }
     }
     $revision->postLoad();
 }