File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php namespace Tatter \Assets \Commands ;
2+
3+ use CodeIgniter \CLI \BaseCommand ;
4+ use CodeIgniter \CLI \CLI ;
5+ use Config \Services ;
6+
7+ class Publish extends BaseCommand
8+ {
9+ protected $ group = 'Publication ' ;
10+ protected $ name = 'assets:publish ' ;
11+ protected $ description = "Scans for manifest files and publishes matching assets. " ;
12+ protected $ usage = "assets:publish " ;
13+
14+ public function run (array $ params )
15+ {
16+ helper ('inflector ' );
17+ $ manifests = Services::manifests ();
18+
19+ $ count = 0 ;
20+ foreach ($ manifests ->locate () as $ path )
21+ {
22+ if (! $ manifest = $ manifests ->parse ($ path ))
23+ {
24+ CLI ::write ('Unable to parse manifest from ' . $ path );
25+ $ this ->displayMessages ($ manifests ->getMessages ());
26+ continue ;
27+ }
28+
29+ if (! $ manifests ->publish ($ manifest ))
30+ {
31+ CLI ::write ('Unable to publish manifest from ' . $ path );
32+ $ this ->displayMessages ($ manifests ->getMessages ());
33+ continue ;
34+ }
35+
36+ CLI ::write ('Published ' . basename ($ path ));
37+ $ count ++;
38+ }
39+
40+ if ($ count == 0 )
41+ {
42+ CLI ::write ('No manifests published. ' );
43+ }
44+ else
45+ {
46+ CLI ::write (counted ($ count , 'manifests ' ) . ' published. ' , 'green ' );
47+ }
48+ }
49+
50+ protected function displayMessages (array $ messages )
51+ {
52+ foreach ($ messages as $ message )
53+ {
54+ CLI ::write (...$ message );
55+ }
56+ }
57+ }
You can’t perform that action at this time.
0 commit comments