Skip to content

Commit

Permalink
Add support to Symfony 7.0. Remove support for Symfony 4.4. Update te…
Browse files Browse the repository at this point in the history
…st matrix, fix sf6 deprecation in command and remove sf4.4 coee path
  • Loading branch information
ulrich committed Dec 20, 2023
1 parent 377941a commit 54ca0ae
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.4, 8.0, 8.1]
symfony: [4.4.*, 5.4.*, 6.0.*]
php: [7.4, 8.0, 8.1, 8.2, 8.3]
symfony: [5.4.*, 6.4.*, 7.0.*]
exclude:
- php: 7.4
symfony: 6.0.*
symfony: 6.4.*
- php: 7.4
symfony: 7.0.*
- php: 8.0
symfony: 6.4.*
- php: 8.0
symfony: 7.0.*
- php: 8.1
symfony: 7.0.*

services:
rabbitmq:
Expand Down
21 changes: 6 additions & 15 deletions Broker/Publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
use Psr\Log\NullLogger;
use Swarrot\Broker\Message;
use Swarrot\SwarrotBundle\Event\MessagePublishedEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as ContractsEventDispatcherInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

class Publisher
{
/** @var FactoryInterface */
protected $factory;
/** @var ContractsEventDispatcherInterface|EventDispatcherInterface */
/** @var EventDispatcherInterface */
protected $eventDispatcher;
/** @var array */
protected $messageTypes;
Expand Down Expand Up @@ -50,18 +49,10 @@ public function publish(string $messageType, Message $message, array $overridenC

$messagePublisher->publish($message, $routingKey);

if ($this->eventDispatcher instanceof ContractsEventDispatcherInterface) {
$this->eventDispatcher->dispatch(
new MessagePublishedEvent($messageType, $message, $connection, $exchange, $routingKey),
MessagePublishedEvent::NAME
);
} else {
// Dispatch the old way as we are using Event Dispatcher < 4.3
$this->eventDispatcher->dispatch(
MessagePublishedEvent::NAME,
new MessagePublishedEvent($messageType, $message, $connection, $exchange, $routingKey)
);
}
$this->eventDispatcher->dispatch(
new MessagePublishedEvent($messageType, $message, $connection, $exchange, $routingKey),
MessagePublishedEvent::NAME
);
}

public function isKnownMessageType(string $messageType): bool
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- Add support to Symfony 7.0
- - Remove Symfony <5.4 support

## 2.4.1 - 2022-03-07

- Make command lazy loadable
Expand Down
7 changes: 2 additions & 5 deletions Command/SwarrotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ class SwarrotCommand extends Command
/** @var array */
protected $aliases;

/** @var string */
protected static $defaultDescription = 'Consume messages from a given queue';

public function __construct(
FactoryInterface $swarrotFactory,
string $name,
Expand Down Expand Up @@ -65,7 +62,7 @@ protected function configure(): void
$this
->setName('swarrot:consume:'.$this->name)
->setAliases($this->aliases)
->setDescription(self::$defaultDescription)
->setDescription('Consume messages from a given queue')
->addArgument('queue', InputArgument::OPTIONAL, 'Queue to consume', $this->queue)
->addArgument('connection', InputArgument::OPTIONAL, 'Connection to use', $this->connectionName)
->addOption(
Expand Down Expand Up @@ -117,7 +114,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$consumer->consume($options);

return 0;
return Command::SUCCESS;
}

protected function getOptions(InputInterface $input): array
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"php": "^7.4|^8.0",
"psr/log": "^1.0|^2.0|^3.0",
"swarrot/swarrot": "^4.0",
"symfony/config": "^4.4|^5.4|^6.0",
"symfony/console": "^4.4|^5.4|^6.0",
"symfony/dependency-injection": "^4.4|^5.4|^6.0",
"symfony/http-kernel": "^4.4|^5.4|^6.0",
"symfony/yaml": "^4.4|^5.4|^6.0"
"symfony/config": "^5.4|^6.0|^7.0",
"symfony/console": "^5.4|^6.0|^7.0",
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
"symfony/http-kernel": "^5.4|^6.0|^7.0",
"symfony/yaml": "^5.4|^6.0|^7.0"
},
"require-dev": {
"doctrine/common": "^2.9|^3.0",
Expand All @@ -30,8 +30,8 @@
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "^1.2",
"phpunit/phpunit": "^9.5",
"symfony/event-dispatcher": "^4.4|^5.4|^6.0",
"symfony/phpunit-bridge": "^4.4|^5.4|^6.0"
"symfony/event-dispatcher": "^5.4|^6.0|^7.0",
"symfony/phpunit-bridge": "^5.4|^6.0|^7.0"
},
"suggest": {
"php-amqplib/php-amqplib": "Required if using amqp_lib"
Expand Down

0 comments on commit 54ca0ae

Please sign in to comment.