22
33namespace librarianphp \Create ;
44
5+ use Minicli \FileNotFoundException ;
56use Minicli \Stencil ;
67use Minicli \Command \CommandController ;
78use Minicli \Input ;
89
910class ContentController extends CommandController
1011{
12+ /**
13+ * @throws FileNotFoundException
14+ */
1115 public function handle (): void
1216 {
1317 if (!$ this ->getApp ()->config ->has ('stencil_dir ' )) {
14- $ this ->getApp ()-> getPrinter ()-> error ("You must define a stencil_dir config option. " );
18+ $ this ->error ("You must define a stencil_dir config option. " );
1519 return ;
1620 }
1721
1822 if (!$ this ->getApp ()->config ->has ('stencil_locations ' )) {
19- $ this ->getApp ()-> getPrinter ()-> error ("You must define a stencil_locations array config option. " );
23+ $ this ->error ("You must define a stencil_locations array config option. " );
2024 return ;
2125 }
2226
@@ -30,10 +34,10 @@ public function handle(): void
3034
3135 $ input = new Input (' ' );
3236
33- $ this ->getPrinter ()-> info ("Content Title: " );
37+ $ this ->info ("Content Title: " );
3438 $ title = $ input ->read ();
3539
36- $ this ->getPrinter ()-> info ("Content Description: " );
40+ $ this ->info ("Content Description: " );
3741 $ description = $ input ->read ();
3842
3943 $ content = $ stencil ->applyTemplate ($ template_name , [
@@ -44,7 +48,7 @@ public function handle(): void
4448 $ save_locations = $ this ->getApp ()->config ->stencil_locations ;
4549
4650 if (!array_key_exists ($ template_name , $ save_locations )) {
47- $ this ->getPrinter ()-> error ("Save location not found for template $ template_name " );
51+ $ this ->error ("Save location not found for template $ template_name " );
4852 return ;
4953 }
5054
@@ -53,7 +57,7 @@ public function handle(): void
5357 $ file = fopen ($ path . '/ ' . $ save_name , 'a+ ' );
5458
5559 fwrite ($ file , $ content );
56- $ this ->getPrinter ()-> info ("Content generated at " . $ path . '/ ' . $ save_name );
60+ $ this ->info ("Content generated at " . $ path . '/ ' . $ save_name );
5761 }
5862
5963 public function slugify ($ title )
0 commit comments