Bonjour, je m'intéresse de prés au processus de pagination de page en utilisant le bundle White-october:

Mais en suivant je n'arrive pas à trouver ou ce remplit le tableau $this->views de la class ViewFactory :

<?php

/*
 * This file is part of the Pagerfanta package.
 *
 * (c) Pablo Díez <pablodip@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Pagerfanta\View;

use Pagerfanta\PagerfantaInterface;
use Pagerfanta\Exception\InvalidArgumentException;

/**
 * ViewFactory.
 *
 * @author Pablo Díez <pablodip@gmail.com>
 */
class ViewFactory implements ViewFactoryInterface
{
    private $views;

    /**
     * Constructor.
     */
    public function __construct()
    {
        $this->views = array();

    }

    /**
     * {@inheritdoc}
     */
    public function set($name, ViewInterface $view)
    {
        $this->views$name] = $view;
    }

    /**
     * {@inheritdoc}
     */
    public function has($name)
    {
        return isset($this->views$name]);
    }

    /**
     * {@inheritdoc}
     */
    public function add(array $views)
    {
        foreach ($views as $name => $view) {
            $this->set($name, $view);
        }
    }

    /**
     * {@inheritdoc}
     */
    public function get($name)
    {
        if (!$this->has($name)) {
            throw new InvalidArgumentException(sprintf('The view "%s" does not exist.', $name));
        }

        return $this->views$name];
    }

    /**
     * {@inheritdoc}
     */
    public function remove($name)
    {
        if (!$this->has($name)) {
            throw new InvalidArgumentException(sprintf('The view "%s" does not exist.', $name));
        }

        unset($this->views$name]);
    }

    /**
     * {@inheritdoc}
     */
    public function all()
    {
        return $this->views;
    }

    /**
     * {@inheritdoc}
     */
    public function clear()
    {
        $this->views = array();
    }
}

car pour afficher ma pagination j'utilise la methode:

public function renderPagerfanta(PagerfantaInterface $pagerfanta, $viewName = null, array $options = array())
    {
        if (null === $viewName) {
            $viewName = $this->container->getParameter('white_october_pagerfanta.default_view');
        }

        $routeGenerator = $this->createRouteGenerator($options);

        return $this->container->get('white_october_pagerfanta.view_factory')->get($viewName)->render($pagerfanta, $routeGenerator, $options);
    }

le service "$this->container->get('white_october_pagerfanta.view_factory')" me renvoie la class ViewFactory beaucoup plus haut puis la methode get de la class ViewFactory me renvoi un objet "object(Pagerfanta\View\TwitterBootstrapView)"à la clé "twitter_bootstrap" dans le tableau $this->views$name]
Voir ci dessous:

public function get($name)
    {
        if (!$this->has($name)) {
            throw new InvalidArgumentException(sprintf('The view "%s" does not exist.', $name));
        }
var_dump($this->views$name]);exit;
        return $this->views$name];
    }

resultat du var_dump($this->views$name]) $name ayant pour valeur la clé "twitter_bootstrap"

object(Pagerfanta\View\TwitterBootstrapView)[655]
  private 'template' (Pagerfanta\View\DefaultView) => 
    object(Pagerfanta\View\Template\TwitterBootstrapTemplate)[656]
      private 'routeGenerator' (Pagerfanta\View\Template\Template) => null
      private 'options' (Pagerfanta\View\Template\Template) => 
        array (size=12)
          'prev_message' => string '← Previous' (length=15)
          'prev_disabled_href' => string '#' (length=1)
          'next_message' => string 'Next →' (length=11)
          'next_disabled_href' => string '#' (length=1)
          'dots_message' => string '…' (length=8)
          'dots_href' => string '#' (length=1)
          'css_container_class' => string 'pagination' (length=10)
          'css_prev_class' => string 'prev' (length=4)
          'css_next_class' => string 'next' (length=4)
          'css_disabled_class' => string 'disabled' (length=8)
          'css_dots_class' => string 'disabled' (length=8)
          'css_active_class' => string 'active' (length=6)
  private 'pagerfanta' (Pagerfanta\View\DefaultView) => null
  private 'proximity' (Pagerfanta\View\DefaultView) => null
  private 'currentPage' (Pagerfanta\View\DefaultView) => null
  private 'nbPages' (Pagerfanta\View\DefaultView) => null
  private 'startPage' (Pagerfanta\View\DefaultView) => null
  private 'endPage' (Pagerfanta\View\DefaultView) => null

affichage du tableau var_dump($this->views):

array (size=6)
  'default' => 
    object(Pagerfanta\View\DefaultView)[634]
      private 'template' => 
        object(Pagerfanta\View\Template\DefaultTemplate)[654]
          private 'routeGenerator' (Pagerfanta\View\Template\Template) => null
          private 'options' (Pagerfanta\View\Template\Template) => 
            array (size=9)
              ...
      private 'pagerfanta' => null
      private 'proximity' => null
      private 'currentPage' => null
      private 'nbPages' => null
      private 'startPage' => null
      private 'endPage' => null
  'default_translated' => 
    object(WhiteOctober\PagerfantaBundle\View\DefaultTranslatedView)[660]
      private 'view' (WhiteOctober\PagerfantaBundle\View\TranslatedView) => 
        object(Pagerfanta\View\DefaultView)[634]
          private 'template' => 
            object(Pagerfanta\View\Template\DefaultTemplate)[654]
              ...
          private 'pagerfanta' => null
          private 'proximity' => null
          private 'currentPage' => null
          private 'nbPages' => null
          private 'startPage' => null
          private 'endPage' => null
      private 'translator' (WhiteOctober\PagerfantaBundle\View\TranslatedView) => 
        object(Symfony\Bundle\FrameworkBundle\Translation\Translator)[75]
          protected 'container' => 
            object(appDevDebugProjectContainer)[307]
              ...
          protected 'options' => 
            array (size=2)
              ...
          protected 'loaderIds' => 
            array (size=10)
              ...
          protected 'catalogues' => 
            array (size=0)
              ...
          protected 'locale' => null
          private 'fallbackLocales' (Symfony\Component\Translation\Translator) => 
            array (size=1)
              ...
          private 'loaders' (Symfony\Component\Translation\Translator) => 
            array (size=0)
              ...
          private 'resources' (Symfony\Component\Translation\Translator) => 
            array (size=49)
              ...
          private 'selector' (Symfony\Component\Translation\Translator) => 
            object(Symfony\Component\Translation\MessageSelector)[74]
              ...
  'twitter_bootstrap' => 
    object(Pagerfanta\View\TwitterBootstrapView)[655]
      private 'template' (Pagerfanta\View\DefaultView) => 
        object(Pagerfanta\View\Template\TwitterBootstrapTemplate)[656]
          private 'routeGenerator' (Pagerfanta\View\Template\Template) => null
          private 'options' (Pagerfanta\View\Template\Template) => 
            array (size=12)
              ...
      private 'pagerfanta' (Pagerfanta\View\DefaultView) => null
      private 'proximity' (Pagerfanta\View\DefaultView) => null
      private 'currentPage' (Pagerfanta\View\DefaultView) => null
      private 'nbPages' (Pagerfanta\View\DefaultView) => null
      private 'startPage' (Pagerfanta\View\DefaultView) => null
      private 'endPage' (Pagerfanta\View\DefaultView) => null
  'twitter_bootstrap3' => 
    object(Pagerfanta\View\TwitterBootstrap3View)[657]
      private 'template' (Pagerfanta\View\DefaultView) => 
        object(Pagerfanta\View\Template\TwitterBootstrap3Template)[658]
          private 'routeGenerator' (Pagerfanta\View\Template\Template) => null
          private 'options' (Pagerfanta\View\Template\Template) => 
            array (size=12)
              ...
      private 'pagerfanta' (Pagerfanta\View\DefaultView) => null
      private 'proximity' (Pagerfanta\View\DefaultView) => null
      private 'currentPage' (Pagerfanta\View\DefaultView) => null
      private 'nbPages' (Pagerfanta\View\DefaultView) => null
      private 'startPage' (Pagerfanta\View\DefaultView) => null
      private 'endPage' (Pagerfanta\View\DefaultView) => null
  'twitter_bootstrap3_translated' => 
    object(WhiteOctober\PagerfantaBundle\View\TwitterBootstrap3TranslatedView)[661]
      private 'view' (WhiteOctober\PagerfantaBundle\View\TranslatedView) => 
        object(Pagerfanta\View\TwitterBootstrap3View)[657]
          private 'template' (Pagerfanta\View\DefaultView) => 
            object(Pagerfanta\View\Template\TwitterBootstrap3Template)[658]
              ...
          private 'pagerfanta' (Pagerfanta\View\DefaultView) => null
          private 'proximity' (Pagerfanta\View\DefaultView) => null
          private 'currentPage' (Pagerfanta\View\DefaultView) => null
          private 'nbPages' (Pagerfanta\View\DefaultView) => null
          private 'startPage' (Pagerfanta\View\DefaultView) => null
          private 'endPage' (Pagerfanta\View\DefaultView) => null
      private 'translator' (WhiteOctober\PagerfantaBundle\View\TranslatedView) => 
        object(Symfony\Bundle\FrameworkBundle\Translation\Translator)[75]
          protected 'container' => 
            object(appDevDebugProjectContainer)[307]
              ...
          protected 'options' => 
            array (size=2)
              ...
          protected 'loaderIds' => 
            array (size=10)
              ...
          protected 'catalogues' => 
            array (size=0)
              ...
          protected 'locale' => null
          private 'fallbackLocales' (Symfony\Component\Translation\Translator) => 
            array (size=1)
              ...
          private 'loaders' (Symfony\Component\Translation\Translator) => 
            array (size=0)
              ...
          private 'resources' (Symfony\Component\Translation\Translator) => 
            array (size=49)
              ...
          private 'selector' (Symfony\Component\Translation\Translator) => 
            object(Symfony\Component\Translation\MessageSelector)[74]
              ...
  'twitter_bootstrap_translated' => 
    object(WhiteOctober\PagerfantaBundle\View\TwitterBootstrapTranslatedView)[662]
      private 'view' (WhiteOctober\PagerfantaBundle\View\TranslatedView) => 
        object(Pagerfanta\View\TwitterBootstrapView)[655]
          private 'template' (Pagerfanta\View\DefaultView) => 
            object(Pagerfanta\View\Template\TwitterBootstrapTemplate)[656]
              ...
          private 'pagerfanta' (Pagerfanta\View\DefaultView) => null
          private 'proximity' (Pagerfanta\View\DefaultView) => null
          private 'currentPage' (Pagerfanta\View\DefaultView) => null
          private 'nbPages' (Pagerfanta\View\DefaultView) => null
          private 'startPage' (Pagerfanta\View\DefaultView) => null
          private 'endPage' (Pagerfanta\View\DefaultView) => null
      private 'translator' (WhiteOctober\PagerfantaBundle\View\TranslatedView) => 
        object(Symfony\Bundle\FrameworkBundle\Translation\Translator)[75]
          protected 'container' => 
            object(appDevDebugProjectContainer)[307]
              ...
          protected 'options' => 
            array (size=2)
              ...
          protected 'loaderIds' => 
            array (size=10)
              ...
          protected 'catalogues' => 
            array (size=0)
              ...
          protected 'locale' => null
          private 'fallbackLocales' (Symfony\Component\Translation\Translator) => 
            array (size=1)
              ...
          private 'loaders' (Symfony\Component\Translation\Translator) => 
            array (size=0)
              ...
          private 'resources' (Symfony\Component\Translation\Translator) => 
            array (size=49)
              ...
          private 'selector' (Symfony\Component\Translation\Translator) => 
            object(Symfony\Component\Translation\MessageSelector)[74]
              ...

Donc je me casse la téte pour savoir ou la class VieFactory rempli ce fameux tableau $this->views

Une idée les amis

Merci

1 réponse


Et concernant le service white_october_pagerfanta.view_factory ? Il est défini comment ?

Je connais pas ce bundle... L'objectif c'est de faire de la pagination c'est ça ? Car KngPaginatorBundle le gère bien, et intègre bootstrap 3 ;-)