diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..112bdeafe --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +services: + mercure: + image: dunglas/mercure + environment: + SERVER_NAME: :1337 + MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!' + MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!' + MERCURE_EXTRA_DIRECTIVES: | + anonymous + cors_origins * + ports: + - 1337:1337 diff --git a/src/Maker/MakeEntity.php b/src/Maker/MakeEntity.php index 8b12b4a7f..0fa1508e6 100644 --- a/src/Maker/MakeEntity.php +++ b/src/Maker/MakeEntity.php @@ -20,6 +20,7 @@ use Symfony\Bundle\MakerBundle\Doctrine\EntityRegenerator; use Symfony\Bundle\MakerBundle\Doctrine\EntityRelation; use Symfony\Bundle\MakerBundle\Doctrine\ORMDependencyBuilder; +use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException; use Symfony\Bundle\MakerBundle\FileManager; use Symfony\Bundle\MakerBundle\Generator; use Symfony\Bundle\MakerBundle\InputAwareMakerInterface; @@ -31,6 +32,7 @@ use Symfony\Bundle\MakerBundle\Util\CliOutputHelper; use Symfony\Bundle\MakerBundle\Util\PhpCompatUtil; use Symfony\Bundle\MakerBundle\Validator; +use Symfony\Bundle\MercureBundle\DependencyInjection\MercureExtension; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -149,6 +151,11 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma && class_exists(Broadcast::class) && !class_exists($this->generator->createClassNameDetails($entityClassName, 'Entity\\')->getFullName()) ) { + // Mercure is needed + if (!class_exists(MercureExtension::class)) { + throw new RuntimeCommandException('Please run "composer require symfony/mercure". It is needed to broadcast entities.'); + } + $description = $command->getDefinition()->getOption('broadcast')->getDescription(); $question = new ConfirmationQuestion($description, false); $isBroadcast = $io->askQuestion($question); @@ -321,7 +328,7 @@ public function configureDependencies(DependencyBuilder $dependencies, ?InputInt if (null !== $input && $input->getOption('broadcast')) { $dependencies->addClassDependency( Broadcast::class, - 'ux-turbo-mercure' + 'ux-turbo' ); } diff --git a/tests/Maker/MakeEntityTest.php b/tests/Maker/MakeEntityTest.php index fbe885990..f96b43398 100644 --- a/tests/Maker/MakeEntityTest.php +++ b/tests/Maker/MakeEntityTest.php @@ -44,18 +44,12 @@ private function createMakeEntityTestForMercure(): MakerTestDetails ; } - // @legacy - MakeEntity uses ux-turbo-mercure (archived), it needs to use ux-turbo (mercure built in) for Symfony 7.0 - if ('7.0.x-dev' === $_SERVER['SYMFONY_VERSION']) { - return $this->createMakerTest() - ->skipTest('symfony/ux-turbo-mercure is not supported on Symfony 7.') - ; - } - return $this->createMakeEntityTest() ->preRun(function (MakerTestRunner $runner) { // installed manually later so that the compatibility check can run first - $runner->runProcess('composer require symfony/ux-turbo-mercure'); + $runner->runProcess('composer require symfony/ux-turbo'); }) + ->addExtraDependencies('mercure', 'twig') ; }