5
5
use Doctrine \Common \EventManager ;
6
6
use Doctrine \RST \Builder ;
7
7
use Doctrine \RST \Configuration ;
8
+ use Doctrine \RST \ErrorManager ;
8
9
use Doctrine \RST \Event \PostBuildRenderEvent ;
10
+ use Doctrine \RST \Event \PreNodeRenderEvent ;
9
11
use Doctrine \RST \Meta \Metas ;
10
12
use Symfony \Component \Console \Command \Command ;
11
13
use Symfony \Component \Console \Input \InputArgument ;
21
23
use SymfonyDocsBuilder \KernelFactory ;
22
24
use SymfonyDocsBuilder \Listener \AssetsCopyListener ;
23
25
use SymfonyDocsBuilder \Listener \BuildProgressListener ;
24
- use SymfonyDocsBuilder \Listener \CopyImagesDirectoryListener ;
26
+ use SymfonyDocsBuilder \Listener \CopyImagesListener ;
25
27
26
28
class BuildDocsCommand extends Command
27
29
{
@@ -96,6 +98,8 @@ protected function initialize(InputInterface $input, OutputInterface $output)
96
98
$ filesystem ->remove ($ htmlOutputDir );
97
99
}
98
100
101
+ $ filesystem ->mkdir ($ htmlOutputDir );
102
+
99
103
$ parseSubPath = $ input ->getOption ('parse-sub-path ' );
100
104
if ($ parseSubPath && $ input ->getOption ('output-json ' )) {
101
105
throw new \InvalidArgumentException ('Cannot pass both --parse-sub-path and --output-json options. ' );
@@ -120,7 +124,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
120
124
KernelFactory::createKernel ($ this ->buildContext , $ this ->urlChecker ?? null )
121
125
);
122
126
123
- $ this ->initializeListeners ($ builder ->getConfiguration ()->getEventManager ());
127
+ $ this ->addProgressListener ($ builder ->getConfiguration ()->getEventManager ());
124
128
125
129
$ builder ->build (
126
130
$ this ->buildContext ->getSourceDir (),
@@ -175,20 +179,8 @@ private function renderDocForPDF(Metas $metas)
175
179
$ htmlForPdfGenerator ->generateHtmlForPdf ();
176
180
}
177
181
178
- private function initializeListeners (EventManager $ eventManager )
182
+ private function addProgressListener (EventManager $ eventManager )
179
183
{
180
- $ eventManager ->addEventListener (
181
- PostBuildRenderEvent::POST_BUILD_RENDER ,
182
- new CopyImagesDirectoryListener ($ this ->buildContext )
183
- );
184
-
185
- if (!$ this ->buildContext ->getParseSubPath ()) {
186
- $ eventManager ->addEventListener (
187
- [PostBuildRenderEvent::POST_BUILD_RENDER ],
188
- new AssetsCopyListener ($ this ->buildContext ->getOutputDir ())
189
- );
190
- }
191
-
192
184
$ progressListener = new BuildProgressListener ($ this ->io );
193
185
$ progressListener ->attachListeners ($ eventManager );
194
186
}
0 commit comments