20
20
use Symfony \Bundle \MakerBundle \Generator ;
21
21
use Symfony \Bundle \MakerBundle \InputConfiguration ;
22
22
use Symfony \Bundle \MakerBundle \Util \CliOutputHelper ;
23
+ use Symfony \Bundle \MakerBundle \Util \MakerFileLinkFormatter ;
23
24
use Symfony \Component \Console \Application ;
24
25
use Symfony \Component \Console \Command \Command ;
25
26
use Symfony \Component \Console \Input \ArgvInput ;
@@ -34,8 +35,10 @@ final class MakeMigration extends AbstractMaker implements ApplicationAwareMaker
34
35
{
35
36
private Application $ application ;
36
37
37
- public function __construct (private string $ projectDir )
38
- {
38
+ public function __construct (
39
+ private string $ projectDir ,
40
+ private ?MakerFileLinkFormatter $ makerFileLinkFormatter = null ,
41
+ ) {
39
42
}
40
43
41
44
public static function getCommandName (): string
@@ -116,13 +119,15 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
116
119
return ;
117
120
}
118
121
119
- $ this ->writeSuccessMessage ($ io );
122
+ $ absolutePath = $ this ->getGeneratedMigrationFilename ($ migrationOutput );
123
+ $ relativePath = str_replace ($ this ->projectDir .'/ ' , '' , $ absolutePath );
120
124
121
- $ migrationName = $ this ->getGeneratedMigrationFilename ($ migrationOutput );
125
+ $ io ->comment ('<fg=blue>created</>: ' .($ this ->makerFileLinkFormatter ?->makeLinkedPath($ absolutePath , $ relativePath ) ?? $ relativePath ));
126
+
127
+ $ this ->writeSuccessMessage ($ io );
122
128
123
129
$ 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 ()),
126
131
'See <fg=yellow>https://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html</> ' ,
127
132
]);
128
133
}
@@ -148,12 +153,12 @@ public function configureDependencies(DependencyBuilder $dependencies)
148
153
149
154
private function getGeneratedMigrationFilename (string $ migrationOutput ): string
150
155
{
151
- preg_match ('#"(.*?)"# ' , $ migrationOutput , $ matches );
156
+ preg_match ('#"<info> (.*?)</info> "# ' , $ migrationOutput , $ matches );
152
157
153
- if (!isset ($ matches [0 ])) {
158
+ if (!isset ($ matches [1 ])) {
154
159
throw new \Exception ('Your migration generated successfully, but an error occurred printing the summary of what occurred. ' );
155
160
}
156
161
157
- return str_replace ( $ this -> projectDir . ' / ' , '' , $ matches [0 ]) ;
162
+ return $ matches [1 ] ;
158
163
}
159
164
}
0 commit comments