-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from elkmod/feature/landing-pages
Feature: Added support for CMS landing pages
- Loading branch information
Showing
9 changed files
with
355 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace SwagShopwarePwa\Pwa\PageLoader; | ||
|
||
use Shopware\Core\Content\LandingPage\SalesChannel\AbstractLandingPageRoute; | ||
use Shopware\Core\Content\LandingPage\SalesChannel\LandingPageRoute; | ||
use SwagShopwarePwa\Pwa\PageLoader\Context\PageLoaderContext; | ||
use SwagShopwarePwa\Pwa\PageResult\Landing\LandingPageResult; | ||
use SwagShopwarePwa\Pwa\PageResult\Landing\LandingPageResultHydrator; | ||
|
||
/** | ||
* This class loads a static landing page. Landing pages behave the same way as CMS pages, but do not have a breadcrumb. | ||
* | ||
* @package SwagShopwarePwa\Pwa\PageLoader | ||
*/ | ||
class LandingPageLoader implements PageLoaderInterface | ||
{ | ||
private const RESOURCE_TYPE = 'frontend.landing.page'; | ||
|
||
/** | ||
* @var LandingPageRoute | ||
*/ | ||
private $landingPageRoute; | ||
|
||
/** | ||
* @var LandingPageResultHydrator | ||
*/ | ||
private $resultHydrator; | ||
|
||
public function __construct(AbstractLandingPageRoute $landingPageRoute, LandingPageResultHydrator $resultHydrator) | ||
{ | ||
$this->landingPageRoute = $landingPageRoute; | ||
$this->resultHydrator = $resultHydrator; | ||
} | ||
|
||
public function getResourceType(): string | ||
{ | ||
return self::RESOURCE_TYPE; | ||
} | ||
|
||
/** | ||
* @param PageLoaderContext $pageLoaderContext | ||
* | ||
* @return LandingPageResult | ||
*/ | ||
public function load(PageLoaderContext $pageLoaderContext): LandingPageResult | ||
{ | ||
$landingPageResult = $this->landingPageRoute->load( | ||
$pageLoaderContext->getResourceIdentifier(), | ||
$pageLoaderContext->getRequest(), | ||
$pageLoaderContext->getContext() | ||
); | ||
|
||
$pageResult = $this->resultHydrator->hydrate( | ||
$pageLoaderContext, | ||
$landingPageResult->getLandingPage()->getCmsPage() ?? null | ||
); | ||
|
||
return $pageResult; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace SwagShopwarePwa\Pwa\PageResult\Landing; | ||
|
||
use Shopware\Core\Content\Category\CategoryEntity; | ||
use Shopware\Core\Content\Cms\CmsPageEntity; | ||
use SwagShopwarePwa\Pwa\PageResult\AbstractPageResult; | ||
|
||
class LandingPageResult extends AbstractPageResult | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace SwagShopwarePwa\Pwa\PageResult\Landing; | ||
|
||
use Shopware\Core\Content\Category\CategoryEntity; | ||
use Shopware\Core\Content\Cms\CmsPageEntity; | ||
use SwagShopwarePwa\Pwa\PageLoader\Context\PageLoaderContext; | ||
use SwagShopwarePwa\Pwa\PageResult\AbstractPageResultHydrator; | ||
|
||
class LandingPageResultHydrator extends AbstractPageResultHydrator | ||
{ | ||
public function hydrate(PageLoaderContext $pageLoaderContext, ?CmsPageEntity $cmsPageEntity): LandingPageResult | ||
{ | ||
$pageResult = new LandingPageResult(); | ||
|
||
$pageResult->setCmsPage($cmsPageEntity); | ||
$pageResult->setResourceType($pageLoaderContext->getResourceType()); | ||
$pageResult->setResourceIdentifier($pageLoaderContext->getResourceIdentifier()); | ||
|
||
return $pageResult; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.