Skip to content

Commit

Permalink
Moved fetching a singleton to its own controller
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjaap committed Jan 6, 2021
1 parent ca9c61e commit 93dee85
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
4 changes: 0 additions & 4 deletions Controller/Direct/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ public function execute()
$contentType = $this->getRequest()
->getParam('type');

if ($uid === 'singleton') {
return $this->page->renderPageBySingleton($contentType);
}

return $this->page->renderPageByUid($uid, $contentType);
}
}
37 changes: 37 additions & 0 deletions Controller/Direct/Singleton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php declare(strict_types=1);

namespace Elgentos\PrismicIO\Controller\Direct;

use Elgentos\PrismicIO\Renderer\Page as PageRenderer;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\App\Action\Action;

class Singleton extends Action implements HttpGetActionInterface, HttpPostActionInterface
{

/** @var PageRenderer */
public $page;

public function __construct(
Context $context,
PageRenderer $page
) {
parent::__construct($context);
$this->page = $page;
}

/**
* View CMS page action
*
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
$contentType = $this->getRequest()
->getParam('type');

return $this->page->renderPageBySingleton($contentType);
}
}

0 comments on commit 93dee85

Please sign in to comment.