2020use Symfony \Bundle \MakerBundle \Generator ;
2121use Symfony \Bundle \MakerBundle \InputConfiguration ;
2222use Symfony \Bundle \MakerBundle \Util \CliOutputHelper ;
23+ use Symfony \Bundle \MakerBundle \Util \MakerFileLinkFormatter ;
2324use Symfony \Component \Console \Application ;
2425use Symfony \Component \Console \Command \Command ;
2526use Symfony \Component \Console \Input \ArgvInput ;
@@ -34,8 +35,10 @@ final class MakeMigration extends AbstractMaker implements ApplicationAwareMaker
3435{
3536 private Application $ application ;
3637
37- public function __construct (private string $ projectDir )
38- {
38+ public function __construct (
39+ private string $ projectDir ,
40+ private ?MakerFileLinkFormatter $ makerFileLinkFormatter = null ,
41+ ) {
3942 }
4043
4144 public static function getCommandName (): string
@@ -116,13 +119,15 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
116119 return ;
117120 }
118121
119- $ this ->writeSuccessMessage ($ io );
122+ $ absolutePath = $ this ->getGeneratedMigrationFilename ($ migrationOutput );
123+ $ relativePath = str_replace ($ this ->projectDir .'/ ' , '' , $ absolutePath );
120124
121- $ migrationName = $ this ->getGeneratedMigrationFilename ($ migrationOutput );
125+ $ io ->comment ('<fg=blue>created</>: ' .($ this ->makerFileLinkFormatter ?->makeLinkedPath($ absolutePath , $ relativePath ) ?? $ relativePath ));
126+
127+ $ this ->writeSuccessMessage ($ io );
122128
123129 $ io ->text ([
124- sprintf ('Next: Review the new migration <info>%s</info> ' , $ migrationName ),
125- sprintf ('Then: Run the migration with <info>%s doctrine:migrations:migrate</info> ' , CliOutputHelper::getCommandPrefix ()),
130+ sprintf ('Review the new migration then run it with <info>%s doctrine:migrations:migrate</info> ' , CliOutputHelper::getCommandPrefix ()),
126131 'See <fg=yellow>https://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html</> ' ,
127132 ]);
128133 }
@@ -148,12 +153,12 @@ public function configureDependencies(DependencyBuilder $dependencies)
148153
149154 private function getGeneratedMigrationFilename (string $ migrationOutput ): string
150155 {
151- preg_match ('#"(.*?)"# ' , $ migrationOutput , $ matches );
156+ preg_match ('#"<info> (.*?)</info> "# ' , $ migrationOutput , $ matches );
152157
153- if (!isset ($ matches [0 ])) {
158+ if (!isset ($ matches [1 ])) {
154159 throw new \Exception ('Your migration generated successfully, but an error occurred printing the summary of what occurred. ' );
155160 }
156161
157- return str_replace ( $ this -> projectDir . ' / ' , '' , $ matches [0 ]) ;
162+ return $ matches [1 ] ;
158163 }
159164}
0 commit comments