diff --git a/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Page.php b/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Page.php index 2001bc006bbb8..8b9766ca311c7 100644 --- a/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Page.php +++ b/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Page.php @@ -58,23 +58,6 @@ public function __construct( $this->storeManager = $storeManager; } - /** - * @deprecated - * @see getDataByPageId(int $pageId) - * - * Get the page data - * - * @param int $pageId - * @return array - * @throws NoSuchEntityException - */ - public function getData(int $pageId): array - { - $page = $this->pageRepository->getById($pageId); - - return $this->convertPageData($page); - } - /** * Returns page data by page_id * @@ -86,7 +69,7 @@ public function getDataByPageId(int $pageId): array { $page = $this->pageRepository->getById($pageId); - return $this->convertPageData($page, false, true); + return $this->convertPageData($page); } /** @@ -101,17 +84,15 @@ public function getDataByPageIdentifier(string $pageIdentifier): array $storeId = (int)$this->storeManager->getStore()->getId(); $page = $this->pageByIdentifier->execute($pageIdentifier, $storeId); - return $this->convertPageData($page, false, true); + return $this->convertPageData($page); } /** * @param PageInterface $page - * @param bool $includePageId - * @param bool $includePageIdentifier * @return array * @throws NoSuchEntityException */ - private function convertPageData(PageInterface $page, $includePageId = true, $includePageIdentifier = false) + private function convertPageData(PageInterface $page) { if (false === $page->isActive()) { throw new NoSuchEntityException(); @@ -128,16 +109,9 @@ private function convertPageData(PageInterface $page, $includePageId = true, $in PageInterface::META_TITLE => $page->getMetaTitle(), PageInterface::META_DESCRIPTION => $page->getMetaDescription(), PageInterface::META_KEYWORDS => $page->getMetaKeywords(), + PageInterface::PAGE_ID => $page->getId(), + PageInterface::IDENTIFIER => $page->getIdentifier(), ]; - - if ($includePageId) { - $pageData[PageInterface::PAGE_ID] = $page->getId(); - } - - if ($includePageIdentifier) { - $pageData[PageInterface::IDENTIFIER] = $page->getIdentifier(); - } - return $pageData; } } diff --git a/app/code/Magento/CmsGraphQl/Model/Resolver/Page.php b/app/code/Magento/CmsGraphQl/Model/Resolver/Page.php index 489a3e0a75c80..fbd8e26030952 100644 --- a/app/code/Magento/CmsGraphQl/Model/Resolver/Page.php +++ b/app/code/Magento/CmsGraphQl/Model/Resolver/Page.php @@ -45,7 +45,7 @@ public function resolve( array $value = null, array $args = null ) { - if (!isset($args['id']) && !isset($args['identifier'])) { + if (!isset($args['id'], $args['identifier'])) { throw new GraphQlInputException(__('"Page id/identifier should be specified')); } @@ -53,52 +53,13 @@ public function resolve( try { if (isset($args['id'])) { - $pageData = $this->getPageDataById($this->getPageId($args)); + $pageData = $this->pageDataProvider->getDataByPageId((int)$args['id']); } elseif (isset($args['identifier'])) { - $pageData = $this->getPageDataByIdentifier($this->getPageIdentifier($args)); + $pageData = $this->pageDataProvider->getDataByPageIdentifier((string)$args['identifier']); } } catch (NoSuchEntityException $e) { throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e); } - return $pageData; } - - /** - * @param array $args - * @return int - */ - private function getPageId(array $args): int - { - return isset($args['id']) ? (int)$args['id'] : 0; - } - - /** - * @param array $args - * @return string - */ - private function getPageIdentifier(array $args): string - { - return isset($args['identifier']) ? (string)$args['identifier'] : ''; - } - - /** - * @param int $pageId - * @return array - * @throws GraphQlNoSuchEntityException - */ - private function getPageDataById(int $pageId): array - { - return $this->pageDataProvider->getDataByPageId($pageId); - } - - /** - * @param string $pageIdentifier - * @return array - * @throws GraphQlNoSuchEntityException - */ - private function getPageDataByIdentifier(string $pageIdentifier): array - { - return $this->pageDataProvider->getDataByPageIdentifier($pageIdentifier); - } }