/** * Determine which view is available for loading * * @param string $page Page to get hierarchy of. * * @return array * @throws Exception When handler doesn't return expected type. */ public function get_view_hierarchy($page) { /** * Get the possible views for specified page: */ $options = Stencil_Handler_Factory::get_hierarchy_handler($page); if (!is_array($options) && !$options instanceof Traversable) { throw new Exception('Expected array got ' . gettype($options)); } if (is_array($options)) { $options = new ArrayIterator($options); } /** * Add archive option for archive pages: */ if ('archived' !== $page && in_array($page, $this->archive_pages, true)) { $this->add_to_options('archived', $options); } /** * Add paged option for paged pages: */ if ('paged' !== $page && is_paged()) { $this->add_to_options('paged', $options); } /** * Convert to array for filtering and return ouput */ $options = iterator_to_array($options); // Apply filter. $options = Stencil_Environment::filter('views-' . $page, $options); return $options; }