Skip to content

Commit

Permalink
Merge pull request #6 from alujane/master
Browse files Browse the repository at this point in the history
[SWPWA-273] - Styling for tables, iframes, fix for cms translations
  • Loading branch information
alfredsgenkins authored Dec 19, 2019
2 parents 98cd444 + 83fc15e commit 8ae780d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 128 deletions.
50 changes: 45 additions & 5 deletions src/Model/Resolver/DataProvider/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

namespace ScandiPWA\CmsGraphQl\Model\Resolver\DataProvider;

use Magento\Framework\Exception\LocalizedException;
use ScandiPWA\CmsGraphQl\Api\Data\PageInterface;
use Magento\Cms\Api\Data\PageInterface as OriginalPageInterface;
use Magento\Cms\Api\GetPageByIdentifierInterface;
use Magento\Cms\Api\PageRepositoryInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Widget\Model\Template\FilterEmulate;
Expand All @@ -22,37 +25,72 @@
class Page extends \Magento\CmsGraphQl\Model\Resolver\DataProvider\Page
{
/**
* @var FilterEmulate
* @var GetPageByIdentifierInterface
*/
private $widgetFilter;
private $pageByIdentifier;

/**
* @var PageRepositoryInterface
*/
private $pageRepository;

/**
* @var FilterEmulate
*/
private $widgetFilter;

/**
* @param PageRepositoryInterface $pageRepository
* @param FilterEmulate $widgetFilter
* @param GetPageByIdentifierInterface $getPageByIdentifier
*/
public function __construct(
PageRepositoryInterface $pageRepository,
FilterEmulate $widgetFilter
FilterEmulate $widgetFilter,
GetPageByIdentifierInterface $getPageByIdentifier
) {

$this->pageRepository = $pageRepository;
$this->widgetFilter = $widgetFilter;
$this->pageByIdentifier = $getPageByIdentifier;
}

/**
* @param int $pageId
* @return array
* @throws NoSuchEntityException
* @throws LocalizedException
*/
public function getData(int $pageId): array
public function getDataByPageId(int $pageId): array
{
$page = $this->pageRepository->getById($pageId);

if (!$page->isActive()) {
return $this->convertPageData($page);
}

/**
* @param string $pageIdentifier
* @param int $storeId
* @return array
* @throws NoSuchEntityException
*/
public function getDataByPageIdentifier(string $pageIdentifier, int $storeId): array
{
$page = $this->pageByIdentifier->execute($pageIdentifier, $storeId);

return $this->convertPageData($page);
}

/**
* Convert page data
*
* @param OriginalPageInterface $page
* @return array
* @throws NoSuchEntityException
*/
private function convertPageData(OriginalPageInterface $page)
{
if (false === $page->isActive()) {
throw new NoSuchEntityException();
}

Expand All @@ -68,6 +106,8 @@ public function getData(int $pageId): array
PageInterface::META_TITLE => $page->getMetaTitle(),
PageInterface::META_DESCRIPTION => $page->getMetaDescription(),
PageInterface::META_KEYWORDS => $page->getMetaKeywords(),
PageInterface::PAGE_ID => $page->getId(),
PageInterface::IDENTIFIER => $page->getIdentifier(),
];

return $pageData;
Expand Down
122 changes: 0 additions & 122 deletions src/Model/Resolver/Page.php

This file was deleted.

1 change: 0 additions & 1 deletion src/etc/graphql/di.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\CmsGraphQl\Model\Resolver\Page" type="ScandiPWA\CmsGraphQl\Model\Resolver\Page"/>
<preference for="Magento\Widget\Model\Template\Filter" type="ScandiPWA\CmsGraphQl\Model\Template\VirtualFilter"/>
<preference for="Magento\Widget\Model\Template\FilterEmulate" type="ScandiPWA\CmsGraphQl\Model\Template\VirtualFilter"/>
<preference for="Magento\CmsGraphQl\Model\Resolver\DataProvider\Page" type="ScandiPWA\CmsGraphQl\Model\Resolver\DataProvider\Page"/>
Expand Down

0 comments on commit 8ae780d

Please sign in to comment.