Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function getViewData(DocumentIterator $result, ViewData $data)
 {
     /** @var ChoicesAwareViewData $data */
     foreach ($this->choices as $key => $choice) {
         $active = $data->getState()->isActive() && strcmp($data->getState()->getValue(), $key) === 0;
         $viewChoice = new ViewData\Choice();
         $viewChoice->setLabel($choice['label']);
         $viewChoice->setDefault($choice['default']);
         $viewChoice->setMode($choice['mode']);
         $viewChoice->setActive($active);
         if ($active) {
             $viewChoice->setUrlParameters($data->getResetUrlParameters());
         } else {
             $viewChoice->setUrlParameters($this->getOptionUrlParameters($key, $data));
         }
         $data->addChoice($viewChoice);
     }
     return $data;
 }
 /**
  * Returns whether choice with the specified key is active.
  *
  * @param string   $key
  * @param ViewData $data
  *
  * @return bool
  */
 protected function isChoiceActive($key, ViewData $data)
 {
     return $data->getState()->isActive() && $data->getState()->getValue() == $key;
 }
 /**
  * {@inheritdoc}
  */
 protected function isChoiceActive($key, ViewData $data)
 {
     return $data->getState()->isActive() && in_array($key, $data->getState()->getValue());
 }
 /**
  * {@inheritdoc}
  */
 public function getViewData(DocumentIterator $result, ViewData $data)
 {
     /** @var ViewData\PagerAwareViewData $data */
     $data->setPager(new PagerService(new CountAdapter($result->getTotalCount()), array_filter(['page' => $data->getState()->getValue(), 'limit' => $this->getCountPerPage(), 'max_pages' => $this->getMaxPages()])));
     return $data;
 }