Skip to content

Commit

Permalink
refactor: Removed deprecated AppController.php and Handler methods. R…
Browse files Browse the repository at this point in the history
…emoved FrontendController.php.
  • Loading branch information
roadiz-ci committed Mar 14, 2024
1 parent 9d0c560 commit 58a7afe
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 104 deletions.
12 changes: 4 additions & 8 deletions src/EntityHandler/CustomFormFieldHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
final class CustomFormFieldHandler extends AbstractHandler
{
private ?CustomFormField $customFormField = null;
private CustomFormHandler $customFormHandler;

public function getCustomFormField(): ?CustomFormField
{
return $this->customFormField;
}
/**
* @param CustomFormField $customFormField
* @return $this
Expand All @@ -34,10 +29,11 @@ public function setCustomFormField(CustomFormField $customFormField): self
* @param ObjectManager $objectManager
* @param CustomFormHandler $customFormHandler
*/
public function __construct(ObjectManager $objectManager, CustomFormHandler $customFormHandler)
{
public function __construct(
ObjectManager $objectManager,
private readonly CustomFormHandler $customFormHandler
) {
parent::__construct($objectManager);
$this->customFormHandler = $customFormHandler;
}

/**
Expand Down
5 changes: 0 additions & 5 deletions src/EntityHandler/CustomFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ final class CustomFormHandler extends AbstractHandler
{
protected ?CustomForm $customForm = null;

public function getCustomForm(): ?CustomForm
{
return $this->customForm;
}

public function setCustomForm(CustomForm $customForm): self
{
$this->customForm = $customForm;
Expand Down
11 changes: 0 additions & 11 deletions src/EntityHandler/TagHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@ final class TagHandler extends AbstractHandler
{
private ?Tag $tag = null;

/**
* @return Tag
*/
public function getTag(): Tag
{
if (null === $this->tag) {
throw new \BadMethodCallException('Tag is null');
}
return $this->tag;
}

/**
* @param Tag $tag
* @return $this
Expand Down
11 changes: 0 additions & 11 deletions src/EntityHandler/TranslationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ final class TranslationHandler extends AbstractHandler
{
private ?TranslationInterface $translation = null;

/**
* @return TranslationInterface
*/
public function getTranslation(): TranslationInterface
{
if (null === $this->translation) {
throw new \BadMethodCallException('Translation is null');
}
return $this->translation;
}

/**
* @param TranslationInterface $translation
*
Expand Down
14 changes: 5 additions & 9 deletions src/Message/Handler/DeleteNodeTypeMessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@

final class DeleteNodeTypeMessageHandler implements MessageHandlerInterface
{
private ManagerRegistry $managerRegistry;
private HandlerFactoryInterface $handlerFactory;
private MessageBusInterface $messageBus;

public function __construct(ManagerRegistry $managerRegistry, HandlerFactoryInterface $handlerFactory, MessageBusInterface $messageBus)
{
$this->managerRegistry = $managerRegistry;
$this->handlerFactory = $handlerFactory;
$this->messageBus = $messageBus;
public function __construct(
private readonly ManagerRegistry $managerRegistry,
private readonly HandlerFactoryInterface $handlerFactory,
private readonly MessageBusInterface $messageBus
) {
}

/**
Expand Down
18 changes: 5 additions & 13 deletions src/Message/Handler/HttpRequestMessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,15 @@
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use RZ\Roadiz\CoreBundle\Message\HttpRequestMessage;
use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;

final class HttpRequestMessageHandler implements MessageHandlerInterface
{
private LoggerInterface $logger;
private ?Client $client;

/**
* @param Client|null $client
* @param LoggerInterface|null $logger
*/
public function __construct(Client $client = null, ?LoggerInterface $logger = null)
{
$this->logger = $logger ?? new NullLogger();
$this->client = $client ?? new Client();
public function __construct(
private readonly LoggerInterface $logger
) {
}

public function __invoke(HttpRequestMessage $message): void
Expand All @@ -35,7 +26,8 @@ public function __invoke(HttpRequestMessage $message): void
$message->getRequest()->getMethod(),
$message->getRequest()->getUri()
));
$this->client->send($message->getRequest(), $message->getOptions());
$client = new Client();
$client->send($message->getRequest(), $message->getOptions());
} catch (GuzzleException $exception) {
throw new UnrecoverableMessageHandlingException($exception->getMessage(), 0, $exception);
}
Expand Down
23 changes: 4 additions & 19 deletions src/Message/Handler/PurgeReverseProxyCacheMessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,12 @@

final class PurgeReverseProxyCacheMessageHandler implements MessageHandlerInterface
{
private UrlGeneratorInterface $urlGenerator;
private ReverseProxyCacheLocator $reverseProxyCacheLocator;
private MessageBusInterface $bus;
private ManagerRegistry $managerRegistry;

/**
* @param MessageBusInterface $bus
* @param UrlGeneratorInterface $urlGenerator
* @param ReverseProxyCacheLocator $reverseProxyCacheLocator
* @param ManagerRegistry $managerRegistry
*/
public function __construct(
MessageBusInterface $bus,
UrlGeneratorInterface $urlGenerator,
ReverseProxyCacheLocator $reverseProxyCacheLocator,
ManagerRegistry $managerRegistry
private readonly MessageBusInterface $bus,
private readonly UrlGeneratorInterface $urlGenerator,
private readonly ReverseProxyCacheLocator $reverseProxyCacheLocator,
private readonly ManagerRegistry $managerRegistry
) {
$this->urlGenerator = $urlGenerator;
$this->reverseProxyCacheLocator = $reverseProxyCacheLocator;
$this->managerRegistry = $managerRegistry;
$this->bus = $bus;
}

public function __invoke(PurgeReverseProxyCacheMessage $message): void
Expand Down
21 changes: 6 additions & 15 deletions src/Message/Handler/SearchRealmNodeInheritanceMessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,12 @@

final class SearchRealmNodeInheritanceMessageHandler implements MessageHandlerInterface
{
private ManagerRegistry $managerRegistry;
private HandlerFactoryInterface $handlerFactory;
private MessageBusInterface $bus;
private LoggerInterface $logger;

public function __construct(
ManagerRegistry $managerRegistry,
HandlerFactoryInterface $handlerFactory,
MessageBusInterface $bus,
LoggerInterface $logger
private readonly ManagerRegistry $managerRegistry,
private readonly HandlerFactoryInterface $handlerFactory,
private readonly MessageBusInterface $bus,
private readonly LoggerInterface $logger
) {
$this->managerRegistry = $managerRegistry;
$this->handlerFactory = $handlerFactory;
$this->bus = $bus;
$this->logger = $logger;
}

public function __invoke(SearchRealmNodeInheritanceMessage $message): void
Expand Down Expand Up @@ -65,7 +56,7 @@ private function clearAnyExistingRealmNodes(Node $node): void
$this->logger->info('Clean existing RealmNode information');
$this->bus->dispatch(new Envelope(new CleanRealmNodeInheritanceMessage(
$autoRealmNode->getNode()->getId(),
null !== $autoRealmNode->getRealm() ? $autoRealmNode->getRealm()->getId() : null
$autoRealmNode->getRealm()->getId()
)));
}
}
Expand All @@ -90,7 +81,7 @@ private function applyRootRealmNodes(Node $node): void
$this->logger->info('Apply new root RealmNode information');
$this->bus->dispatch(new Envelope(new ApplyRealmNodeInheritanceMessage(
$rootRealmNode->getNode()->getId(),
null !== $rootRealmNode->getRealm() ? $rootRealmNode->getRealm()->getId() : null
$rootRealmNode->getRealm()->getId()
)));
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/Message/Handler/UpdateDoctrineSchemaMessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@

final class UpdateDoctrineSchemaMessageHandler implements MessageHandlerInterface
{
private SchemaUpdater $schemaUpdater;

public function __construct(SchemaUpdater $schemaUpdater)
public function __construct(private readonly SchemaUpdater $schemaUpdater)
{
$this->schemaUpdater = $schemaUpdater;
}

/**
Expand Down
14 changes: 5 additions & 9 deletions src/Message/Handler/UpdateNodeTypeSchemaMessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@

final class UpdateNodeTypeSchemaMessageHandler implements MessageHandlerInterface
{
private ManagerRegistry $managerRegistry;
private HandlerFactoryInterface $handlerFactory;
private MessageBusInterface $messageBus;

public function __construct(ManagerRegistry $managerRegistry, HandlerFactoryInterface $handlerFactory, MessageBusInterface $messageBus)
{
$this->managerRegistry = $managerRegistry;
$this->handlerFactory = $handlerFactory;
$this->messageBus = $messageBus;
public function __construct(
private readonly ManagerRegistry $managerRegistry,
private readonly HandlerFactoryInterface $handlerFactory,
private readonly MessageBusInterface $messageBus
) {
}

public function __invoke(UpdateNodeTypeSchemaMessage $message): void
Expand Down

0 comments on commit 58a7afe

Please sign in to comment.