Bundle/AnalyticsBundle/Helper/AnalyticsViewHelper.php
public function getMostReadByViewType($viewNamespace, $number)
    {
        $views = [];

        switch ($viewNamespace) {
            case 'Victoire\Bundle\PageBundle\Entity\Page':

                $viewReferences = [];
                $repo = $this->entityManager->getRepository($viewNamespace);
                //get pages and viewReferenceIds
                foreach ($repo->getAll()->run() as $key => $page) {
                    $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters(
                        [
                            'viewNamespace' => $viewNamespace,
                            'viewId'        => $page->getId(),
                        ]
                    );
                    $viewReferences[$viewReference->getId()] = $viewReference;
                }
                //get pager
                $browseEvents = $this->entityManager->getRepository('Victoire\Bundle\AnalyticsBundle\Entity\BrowseEvent')
                    ->getMostVisitedFromReferences(array_keys($viewReferences), $number)
                    ->getQuery()
                    ->getResult();
                //Now we get the most visited references, we'll get views with PageHelper
                foreach ($browseEvents as $browseEvent) {
                    $views[] = $this->pageHelper->findPageByReference(
                        $viewReferences[$browseEvent->getViewReferenceId()]
                    );
                }

                break;

            default:
                // code...
                break;
        }

        return $views;
    }
public function getMostReadByViewType($viewNamespace, $number)
    {
        $views = [];

        switch ($viewNamespace) {
            case 'Victoire\Bundle\PageBundle\Entity\Page':

                $viewReferences = [];
                $repo = $this->entityManager->getRepository($viewNamespace);
                //get pages and viewReferenceIds
                foreach ($repo->getAll()->run() as $key => $page) {
                    $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters(
                        [
                            'viewNamespace' => $viewNamespace,
                            'viewId'        => $page->getId(),
                        ]
                    );
                    $viewReferences[$viewReference->getId()] = $viewReference;
                }
                //get pager
                $browseEvents = $this->entityManager->getRepository('Victoire\Bundle\AnalyticsBundle\Entity\BrowseEvent')
                    ->getMostVisitedFromReferences(array_keys($viewReferences), $number)
                    ->getQuery()
                    ->getResult();
                //Now we get the most visited references, we'll get views with PageHelper
                foreach ($browseEvents as $browseEvent) {
                    $views[] = $this->pageHelper->findPageByReference(
                        $viewReferences[$browseEvent->getViewReferenceId()]
                    );
                }

                break;

            default:
                // code...
                break;
        }

        return $views;
    }
public function getMostReadByViewType ( $ viewNamespace , $ number ) { $ views = [ ] ; switch ( $ viewNamespace ) { case 'Victoire\Bundle\PageBundle\Entity\Page' : $ viewReferences = [ ] ; $ repo = $ this -> entityManager -> getRepository ( $ viewNamespace ) ; //get pages and viewReferenceIds foreach ( $ repo -> getAll ( ) -> run ( ) as $ key => $ page ) { $ viewReference = $ this -> viewReferenceRepository -> getOneReferenceByParameters ( [ 'viewNamespace' => $ viewNamespace , 'viewId' => $ page -> getId ( ) , ] ) ; $ viewReferences [ $ viewReference -> getId ( ) ] = $ viewReference ; } //get pager $ browseEvents = $ this -> entityManager -> getRepository ( 'Victoire\Bundle\AnalyticsBundle\Entity\BrowseEvent' ) -> getMostVisitedFromReferences ( array_keys ( $ viewReferences ) , $ number ) -> getQuery ( ) -> getResult ( ) ; //Now we get the most visited references, we'll get views with PageHelper foreach ( $ browseEvents as $ browseEvent ) { $ views [ ] = $ this -> pageHelper -> findPageByReference ( $ viewReferences [ $ browseEvent -> getViewReferenceId ( ) ] ) ; } break ; default : // code... break ; } return $ views ; }
Get the most read views by type.

@return View[]
Get the most read views by type .