Skip to content

Commit

Permalink
Merged branch '1.3' of ezsystems/ezplatform-kernel into main
Browse files Browse the repository at this point in the history
  • Loading branch information
alongosz committed Feb 17, 2022
2 parents 9aa3667 + 8037842 commit e3cd9f0
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/bundle/Core/EventListener/ConfigScopeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
*/
namespace Ibexa\Bundle\Core\EventListener;

use Ibexa\Contracts\Core\MVC\EventSubscriber\ConfigScopeChangeSubscriber;
use Ibexa\Core\MVC\Symfony\Configuration\VersatileScopeInterface;
use Ibexa\Core\MVC\Symfony\Event\ScopeChangeEvent;
use Ibexa\Core\MVC\Symfony\MVCEvents;
use Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessAware;
use Ibexa\Core\MVC\Symfony\View\ViewManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class ConfigScopeListener implements EventSubscriberInterface
class ConfigScopeListener implements EventSubscriberInterface, ConfigScopeChangeSubscriber
{
/** @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface[] */
private $configResolvers;
Expand All @@ -40,7 +41,7 @@ public static function getSubscribedEvents()
];
}

public function onConfigScopeChange(ScopeChangeEvent $event)
public function onConfigScopeChange(ScopeChangeEvent $event): void
{
$siteAccess = $event->getSiteAccess();

Expand Down
1 change: 1 addition & 0 deletions src/bundle/Core/Resources/config/fieldtype_services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ services:
ibexa.field_type.ezimage.io_service.published.config_scope_change_aware:
class: Ibexa\Core\IO\ConfigScopeChangeAwareIOService
decorates: ibexa.field_type.ezimage.io_service.published
autoconfigure: true
lazy: true
arguments:
$configResolver: '@ibexa.config.resolver'
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/IO/Resources/config/io.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ services:

# Inject the siteaccess config into a few io services
Ibexa\Core\IO\Adapter\LocalAdapter:
class: Ibexa\Core\IO\Adapter\LocalAdapter
autoconfigure: true
arguments:
- '@Ibexa\Core\IO\IOConfigProvider'
- '@ibexa.config.resolver'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

namespace Ibexa\Contracts\Core\MVC\EventSubscriber;

use Ibexa\Core\MVC\Symfony\SiteAccess;
use Ibexa\Core\MVC\Symfony\Event\ScopeChangeEvent;

/**
* Lets implementing class react to config scope changes.
*/
interface ConfigScopeChangeSubscriber
{
public function onConfigScopeChange(SiteAccess $siteAccess): void;
public function onConfigScopeChange(ScopeChangeEvent $event): void;
}

class_alias(ConfigScopeChangeSubscriber::class, 'eZ\Publish\SPI\MVC\EventSubscriber\ConfigScopeChangeSubscriber');
4 changes: 2 additions & 2 deletions src/lib/IO/Adapter/LocalAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Ibexa\Contracts\Core\MVC\EventSubscriber\ConfigScopeChangeSubscriber;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Ibexa\Core\IO\IOConfigProvider;
use Ibexa\Core\MVC\Symfony\SiteAccess;
use Ibexa\Core\MVC\Symfony\Event\ScopeChangeEvent;
use League\Flysystem\Adapter\Local;
use LogicException;

Expand Down Expand Up @@ -46,7 +46,7 @@ public function __construct(IOConfigProvider $ioConfigProvider, ConfigResolverIn
* Reconfigure Adapter due to SiteAccess change which implies
* root dir and permissions could be different for new SiteAccess.
*/
public function onConfigScopeChange(SiteAccess $siteAccess): void
public function onConfigScopeChange(ScopeChangeEvent $event): void
{
$root = $this->ioConfigProvider->getRootDir();
$root = is_link($root) ? realpath($root) : $root;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/IO/ConfigScopeChangeAwareIOService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Ibexa\Core\IO\Values\BinaryFile;
use Ibexa\Core\IO\Values\BinaryFileCreateStruct;
use Ibexa\Core\MVC\Symfony\SiteAccess;
use Ibexa\Core\MVC\Symfony\Event\ScopeChangeEvent;

class ConfigScopeChangeAwareIOService implements IOServiceInterface, ConfigScopeChangeSubscriber
{
Expand Down Expand Up @@ -113,7 +113,7 @@ public function deleteDirectory($path): void
$this->innerIOService->deleteDirectory($path);
}

public function onConfigScopeChange(SiteAccess $siteAccess): void
public function onConfigScopeChange(ScopeChangeEvent $event): void
{
$this->setPrefix($this->configResolver->getParameter($this->prefixParameterName));
}
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/IO/ConfigScopeChangeAwareIOServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Ibexa\Core\IO\IOServiceInterface;
use Ibexa\Core\IO\Values\BinaryFile;
use Ibexa\Core\IO\Values\BinaryFileCreateStruct;
use Ibexa\Core\MVC\Symfony\SiteAccess;
use Ibexa\Core\MVC\Symfony\Event\ScopeChangeEvent;
use PHPUnit\Framework\TestCase;

final class ConfigScopeChangeAwareIOServiceTest extends TestCase
Expand Down Expand Up @@ -309,13 +309,13 @@ public function testDeleteDirectory(): void

public function testOnConfigScopeChange(): void
{
$siteAccess = $this->createMock(SiteAccess::class);
$event = $this->createMock(ScopeChangeEvent::class);
$this->innerIOService
->expects($this->once())
->method('setPrefix')
->with(self::PREFIX);

$this->ioService->onConfigScopeChange($siteAccess);
$this->ioService->onConfigScopeChange($event);
}
}

Expand Down

0 comments on commit e3cd9f0

Please sign in to comment.