/** * Get an array of pages that have either pending comments or recently approved comments, with page IDs for keys * * @return array */ public function getPages() { $this->_load(); if (null === $this->_pages) { $pages = $this->_pageLoader->getByID($this->_pageIDs); $this->_pages = []; foreach ($pages as $page) { $this->_pages[$page->id] = $page; } } return $this->_pages; }
/** * Check that a no page exists with this slug in its history * * @param Page $page * @param $slug * @throws \InvalidArgumentException Throws exception if $slug is not a string * @throws Exception\SlugUpdateException Throws exception if page exists with slug matching that given * in $slug in its slug history */ private function _checkSlugHistory(Page $page, $slug) { if (!is_string($slug)) { throw new \InvalidArgumentException('Slug must be a string, ' . gettype($slug) . ' given'); } // Check for the slug historically and show deleted ones too $historicalSlug = $this->_pageLoader->getBySlug($slug, true); // If there is a page returned and it's not this page then offer // a link to remove the slug from history and use it anyway if ($historicalSlug && $historicalSlug->id != $page->id) { $slugParts = explode('/', $slug); $newSlug = array_pop($slugParts); throw new Exception\SlugUpdateException('Slug `' . $slug . '` has been used previously and is redirecting to page ' . $historicalSlug->id, 'ms.cms.feedback.force-slug.failure.redirected', ['%slug%' => $slug, '%redirectedUrl%' => $this->_urlGenerator->generate('ms.cp.cms.edit.attributes', ['pageID' => $historicalSlug->id]), '%redirectedTitle%' => $historicalSlug->title, '%forceUrl%' => $this->_urlGenerator->generate('ms.cp.cms.edit.attributes.slug.force', ['pageID' => $page->id, 'slug' => $newSlug])]); } }
/** * @param $shopPageIDs * @throws \InvalidArgumentException */ private function _setShopPages($shopPageIDs) { if (empty($shopPageIDs)) { return; } if (!is_array($shopPageIDs)) { $shopPageIDs = [$shopPageIDs]; } foreach ($shopPageIDs as $id) { if (!is_int($id)) { throw new \InvalidArgumentException('Shop page IDs must all be integers'); } } $pages = (array) $this->_pageLoader->getByID($shopPageIDs); $shopPages = []; foreach ($pages as $page) { $shopPages[$page->id] = $page->title; } reset($shopPages); $this->_shopPages = $shopPages; }
public function __construct(PageLoader $loader) { $loader->includeDeleted(true); $this->_loader = $loader; }