code: public function findForView($id)
      {
          $type = $this->doctrine->getConnection()->fetchColumn('SELECT type FROM page WHERE id=:id', array('id' => $id));
          if (!$type) {
              throw new NotFoundHttpException;
          }
          $types = $this->em->getClassMetadata($this->pageClassName)->discriminatorMap;
  
          $class = $types[$type];
          $repos = $this->em->getRepository($class);
  
          if ($repos instanceof ViewablePageRepository) {
              $ret = $repos->findForView($id);
          } else {
              $ret = $repos->find($id);
          }
  
          if (!$ret) {
              throw new NotFoundHttpException;
          }
          $this->setLoadedPage($ret);
          return $ret;
      }
docs: Find a page in the repository and trigger a view event.
  
  @param string $id
  @return mixed
  
  @throws NotFoundHttpException