Skip to content

Commit

Permalink
Merge branch '3.2-release'
Browse files Browse the repository at this point in the history
  • Loading branch information
pspanja committed Nov 28, 2019
2 parents e5e0120 + 0771b89 commit f02e7e5
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 22 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ eZ Platform Site API changelog
Unreleased
----------

[`3.2.1...master`](https://github.com/netgen/ezplatform-site-api/compare/3.2.1...master)
[`3.2.2...master`](https://github.com/netgen/ezplatform-site-api/compare/3.2.2...master)

* Add `Location::getFirstChild()` method ([#148](https://github.com/netgen/ezplatform-site-api/pull/148))

3.2.2 (28.11.2019)
------------------

[`3.2.1...3.2.2`](https://github.com/netgen/ezplatform-site-api/compare/3.2.1...3.2.2)

* Fix preview of the unpublished Content ([#149](https://github.com/netgen/ezplatform-site-api/pull/149))

3.2.1 (18.11.2019)
------------------

Expand Down
31 changes: 16 additions & 15 deletions bundle/Controller/PreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
use eZ\Publish\Core\MVC\Symfony\Controller\Content\PreviewController as BasePreviewController;
use eZ\Publish\Core\MVC\Symfony\SiteAccess;
use Netgen\Bundle\EzPlatformSiteApiBundle\Routing\UrlAliasRouter;
use Netgen\EzPlatformSiteApi\API\LoadService;
use Netgen\EzPlatformSiteApi\Core\Site\Values\Location as SiteLocation;
use Netgen\EzPlatformSiteApi\Core\Site\Site;
use Symfony\Component\HttpFoundation\Request;

class PreviewController extends BasePreviewController
Expand All @@ -22,9 +21,9 @@ class PreviewController extends BasePreviewController
protected $configResolver;

/**
* @var \Netgen\EzPlatformSiteApi\API\LoadService
* @var \Netgen\EzPlatformSiteApi\Core\Site\Site
*/
protected $loadService;
protected $site;

/**
* @param \eZ\Publish\Core\MVC\ConfigResolverInterface $configResolver
Expand All @@ -34,18 +33,17 @@ public function setConfigResolver(ConfigResolverInterface $configResolver): void
$this->configResolver = $configResolver;
}

/**
* @param \Netgen\EzPlatformSiteApi\API\LoadService $loadService
*/
public function setLoadService(LoadService $loadService): void
public function setSite(Site $site): void
{
$this->loadService = $loadService;
$this->site = $site;
}

/**
* {@inheritdoc}
*
* @throws \Netgen\EzPlatformSiteApi\API\Exceptions\TranslationNotMatchedException
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
*/
protected function getForwardRequest(Location $location, Content $content, SiteAccess $previewSiteAccess, Request $request, $language): Request
{
Expand Down Expand Up @@ -79,6 +77,8 @@ protected function getForwardRequest(Location $location, Content $content, SiteA
* @param string $language
*
* @throws \Netgen\EzPlatformSiteApi\API\Exceptions\TranslationNotMatchedException
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
*/
protected function injectSiteApiValueObjects(Request $request, string $language): void
{
Expand All @@ -87,19 +87,20 @@ protected function injectSiteApiValueObjects(Request $request, string $language)
$content = $request->attributes->get('content');
$location = $request->attributes->get('location');

$siteContent = $this->loadService->loadContent(
$siteContent = $this->site->getLoadService()->loadContent(
$content->id,
$content->versionInfo->versionNo,
$language
);

if (!$location->isDraft()) {
$siteLocation = $this->loadService->loadLocation($location->id);
$siteLocation = $this->site->getLoadService()->loadLocation($location->id);
} else {
$siteLocation = new SiteLocation([
'contentInfo' => $siteContent->contentInfo,
'innerLocation' => $location,
]);
$siteLocation = $this->site->getDomainObjectMapper()->mapLocation(
$location,
$content->versionInfo,
$language
);
}

$requestParams = $request->attributes->get('params');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,29 @@ class PreviewControllerOverridePass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('ezpublish.controller.content.preview.core')) {
$corePreviewControllerServiceId = 'ezpublish.controller.content.preview.core';

if (!$container->hasDefinition($corePreviewControllerServiceId)) {
return;
}

$container
->findDefinition('ezpublish.controller.content.preview.core')
->findDefinition($corePreviewControllerServiceId)
->setClass(PreviewController::class)
->addMethodCall(
'setConfigResolver',
[new Reference('ezpublish.config.resolver')]
)
->addMethodCall(
'setLoadService',
[new Reference('netgen.ezplatform_site.load_service')]
'setSite',
[new Reference('netgen.ezplatform_site.core.site')]
);

// Resetting the alias to the original value
// to disable legacy bridge taking over the preview controller
$container->setAlias(
'ezpublish.controller.content.preview',
'ezpublish.controller.content.preview.core'
$corePreviewControllerServiceId
);
}
}
6 changes: 6 additions & 0 deletions lib/Core/Site/FilterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
use Netgen\EzPlatformSiteApi\API\FilterService as FilterServiceInterface;
use Netgen\EzPlatformSiteApi\API\Settings as BaseSettings;

/**
* @internal
*
* Hint against API interface instead of this service:
* @see \Netgen\EzPlatformSiteApi\API\FilterService
*/
class FilterService implements FilterServiceInterface
{
/**
Expand Down
6 changes: 6 additions & 0 deletions lib/Core/Site/FindService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
use Netgen\EzPlatformSiteApi\API\FindService as FindServiceInterface;
use Netgen\EzPlatformSiteApi\API\Settings as BaseSettings;

/**
* @internal
*
* Hint against API interface instead of this service:
* @see \Netgen\EzPlatformSiteApi\API\FindService
*/
class FindService implements FindServiceInterface
{
/**
Expand Down
6 changes: 6 additions & 0 deletions lib/Core/Site/LoadService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
use Netgen\EzPlatformSiteApi\API\Values\Location;
use Netgen\EzPlatformSiteApi\Core\Site\Exceptions\TranslationNotMatchedException;

/**
* @internal
*
* Hint against API interface instead of this service:
* @see \Netgen\EzPlatformSiteApi\API\LoadService
*/
class LoadService implements LoadServiceInterface
{
/**
Expand Down
6 changes: 6 additions & 0 deletions lib/Core/Site/RelationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
use Netgen\EzPlatformSiteApi\Core\Site\Plugins\FieldType\RelationResolver\Registry as RelationResolverRegistry;
use Netgen\EzPlatformSiteApi\Core\Traits\SearchResultExtractorTrait;

/**
* @internal
*
* Hint against API interface instead of this service:
* @see \Netgen\EzPlatformSiteApi\API\RelationService
*/
class RelationService implements RelationServiceInterface
{
use SearchResultExtractorTrait;
Expand Down
6 changes: 6 additions & 0 deletions lib/Core/Site/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
use eZ\Publish\API\Repository\Exceptions\PropertyReadOnlyException;
use Netgen\EzPlatformSiteApi\API\Settings as BaseSettings;

/**
* @internal
*
* Hint against API abstract class instead of this service:
* @see \Netgen\EzPlatformSiteApi\API\Settings
*/
final class Settings extends BaseSettings
{
/**
Expand Down
10 changes: 9 additions & 1 deletion lib/Core/Site/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;

/**
* @internal
*
* Hint against API interface instead of this service:
* @see \Netgen\EzPlatformSiteApi\API\Site
*/
class Site implements SiteInterface
{
/**
Expand Down Expand Up @@ -160,9 +166,11 @@ public function getRelationService(): APIRelationService
}

/**
* @internal for Site API internal use only
*
* @return \Netgen\EzPlatformSiteApi\Core\Site\DomainObjectMapper
*/
private function getDomainObjectMapper(): DomainObjectMapper
public function getDomainObjectMapper(): DomainObjectMapper
{
if ($this->domainObjectMapper === null) {
$this->domainObjectMapper = new DomainObjectMapper(
Expand Down

0 comments on commit f02e7e5

Please sign in to comment.