Skip to content

Commit a90d68c

Browse files
authored
fix: regressions introduced in #5 (symfony#7)
1 parent 2364545 commit a90d68c

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/Broadcaster/TwigMercureBroadcaster.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ final class TwigMercureBroadcaster implements BroadcasterInterface
4040
{
4141
private $twig;
4242
private $messageBus;
43-
private $publisher = null;
44-
private $expressionLanguage = null;
43+
private $publisher;
44+
private $expressionLanguage;
45+
private $entityNamespace;
4546

4647
private const OPTIONS = [
4748
// Twig options
@@ -65,13 +66,15 @@ public function __construct(
6566
throw new \LogicException('The broadcast feature requires PHP 8.0 or greater, you must either upgrade to PHP 8 or disable it.');
6667
}
6768

68-
if (null === $this->messageBus && null === $this->publisher) {
69+
if (null === $messageBus && null === $publisher) {
6970
throw new \InvalidArgumentException('A message bus or a publisher must be provided.');
7071
}
7172

72-
if (null === $this->expressionLanguage) {
73-
$this->expressionLanguage = new ExpressionLanguage();
74-
}
73+
$this->twig = $twig;
74+
$this->messageBus = $messageBus;
75+
$this->publisher = $publisher;
76+
$this->expressionLanguage = $expressionLanguage ?? new ExpressionLanguage();
77+
$this->entityNamespace = $entityNamespace;
7578
}
7679

7780
public function broadcast(object $entity, string $action): void
@@ -124,7 +127,7 @@ private function normalizeOptions(object $entity, string $action, array $options
124127
$options['topics'] = (array) ($options['topics'] ?? $entityClass);
125128
if (!isset($options['template'])) {
126129
$dir = $entityClass;
127-
if (null !== $this->entityNamespace && 0 !== strpos($entityClass, $this->entityNamespace)) {
130+
if (null !== $this->entityNamespace && 0 === strpos($entityClass, $this->entityNamespace)) {
128131
$dir = substr($entityClass, strlen($this->entityNamespace));
129132
}
130133

src/Doctrine/BroadcastListener.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public function __construct(BroadcasterInterface $broadcaster)
5050
}
5151

5252
$this->reset();
53+
54+
$this->broadcaster = $broadcaster;
5355
}
5456

5557
/**

tests/app/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function registerBundles(): iterable
6060
protected function configureContainer(ContainerConfigurator $container): void
6161
{
6262
$container->extension('framework', [
63-
'test' => 'test' === $_SERVER['APP_ENV'] ?? 'dev',
63+
'test' => 'test' === ($_SERVER['APP_ENV'] ?? 'dev'),
6464
'router' => [
6565
'utf8' => true,
6666
],

0 commit comments

Comments
 (0)