Ejemplo n.º 1
0
 /**
  * @param Options $options
  *
  * @return array
  */
 public function getChoices(Options $options)
 {
     if (!$options['site'] instanceof SiteInterface) {
         return array();
     }
     $filter_choice = array_merge(array('current_page' => false, 'request_method' => 'GET', 'dynamic' => true, 'hierarchy' => 'all'), $options['filter_choice']);
     $pages = $this->manager->loadPages($options['site']);
     $choices = array();
     foreach ($pages as $page) {
         // internal cannot be selected
         if ($page->isInternal()) {
             continue;
         }
         if (!$filter_choice['current_page'] && $options['page'] && $options['page']->getId() == $page->getId()) {
             continue;
         }
         if ('all' != $filter_choice['hierarchy'] && (('root' != $filter_choice['hierarchy'] || $page->getParent()) && ('children' != $filter_choice['hierarchy'] || !$page->getParent()))) {
             continue;
         }
         if ('all' !== $filter_choice['dynamic'] && ($filter_choice['dynamic'] && $page->isDynamic() || !$filter_choice['dynamic'] && !$page->isDynamic())) {
             continue;
         }
         if ('all' != $filter_choice['request_method'] && !$page->hasRequestMethod($filter_choice['request_method'])) {
             continue;
         }
         $choices[$page->getId()] = $page;
         $this->childWalker($page, $options['page'], $choices);
     }
     return $choices;
 }