Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for local dev's to be able to run mercure tests

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
9 changes: 8 additions & 1 deletion src/Maker/MakeEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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'
);
}

Expand Down
10 changes: 2 additions & 8 deletions tests/Maker/MakeEntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ux-turbo installs stimulus-bundle which requires twig. But the twig recipe doesn't get generated in the tmp/cache project. adding it as an extra depend fixes that.

mercure is needed obviously to pub/sub changes

;
}

Expand Down