Skip to content

Commit

Permalink
Merge pull request #5 from dmitrijs-voronovs/cms-page-width
Browse files Browse the repository at this point in the history
CmsPage page_width: added custom PageInterface
  • Loading branch information
alfredsgenkins authored Sep 16, 2019
2 parents 975a19f + 33f44fc commit ed56c0c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
25 changes: 25 additions & 0 deletions src/Api/Data/PageInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* ScandiPWA_CmsGraphQl
*
* @category Scandiweb
* @package ScandiPWA_CmsGraphQl
* @copyright Copyright (c) 2018 Scandiweb, Ltd (https://scandiweb.com)
*/

namespace ScandiPWA\CmsGraphQl\Api\Data;

/**
* CMS page interface.
* @api
* @since 100.0.2
*/
interface PageInterface extends \Magento\Cms\Api\Data\PageInterface
{
/**#@+
* Constants for keys of data array. Identical to the name of the getter in snake case
*/
const URL_KEY = 'url_key';
const PAGE_WIDTH = 'page_width';
/**#@-*/
}
2 changes: 0 additions & 2 deletions src/Model/Page/Source/PageWidth.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class PageWidth implements OptionSourceInterface
{
/**
* @var array
* @deprecated 103.0.1 since the cache is now handled by \Magento\Theme\Model\PageWidth\Config\Builder::$configFiles
*/
protected $options;

Expand All @@ -28,7 +27,6 @@ class PageWidth implements OptionSourceInterface
*/
public function toOptionArray()
{
// $configOptions = $this->pageWidthBuilder->getPageWidthsConfig()->getOptions();
$configOptions = [
'default' => 'default',
'full' => 'full'
Expand Down
8 changes: 4 additions & 4 deletions src/Model/Resolver/DataProvider/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace ScandiPWA\CmsGraphQl\Model\Resolver\DataProvider;

use Magento\Cms\Api\Data\PageInterface;
use ScandiPWA\CmsGraphQl\Api\Data\PageInterface;
use Magento\Cms\Api\PageRepositoryInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Widget\Model\Template\FilterEmulate;
Expand Down Expand Up @@ -52,19 +52,19 @@ public function getData(int $pageId): array
{
$page = $this->pageRepository->getById($pageId);

if (false === $page->isActive()) {
if (!$page->isActive()) {
throw new NoSuchEntityException();
}

$renderedContent = $this->widgetFilter->filter($page->getContent());

$pageData = [
'url_key' => $page->getIdentifier(),
PageInterface::URL_KEY => $page->getIdentifier(),
PageInterface::TITLE => $page->getTitle(),
PageInterface::CONTENT => $renderedContent,
PageInterface::CONTENT_HEADING => $page->getContentHeading(),
PageInterface::PAGE_LAYOUT => $page->getPageLayout(),
'page_width' => $page->getPageWidth() ?: 'default',
PageInterface::PAGE_WIDTH => $page->getPageWidth() ?: 'default',
PageInterface::META_TITLE => $page->getMetaTitle(),
PageInterface::META_DESCRIPTION => $page->getMetaDescription(),
PageInterface::META_KEYWORDS => $page->getMetaKeywords(),
Expand Down
2 changes: 1 addition & 1 deletion src/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="cms_page" resource="default" engine="innodb" comment="CMS Page Table">
<column xsi:type="varchar" name="page_width" nullable="false" default="default" length="255" comment="Page Width"/>
<column xsi:type="varchar" name="page_width" nullable="false" default="default" length="10" comment="Page Width"/>
</table>
</schema>

0 comments on commit ed56c0c

Please sign in to comment.