1212use Utils \ClassUtils ;
1313use Psr \Log \LoggerInterface ;
1414use Parser \Processor \IndexProcessor ;
15+ use Symfony \Component \EventDispatcher \EventDispatcher ;
1516
1617class IndexGenerator
1718{
19+ const BEFORE_GENERATION = 'index.before_generation ' ;
20+ const AFTER_GENERATION = 'index.after_generation ' ;
1821 /**
1922 * Array of plugin classes
2023 * @var array
@@ -63,22 +66,26 @@ class IndexGenerator
6366 */
6467 protected $ processor ;
6568
69+ /** @var EventDispatcher */
70+ protected $ dispatcher ;
71+
6672 public function __construct (
6773 PathResolver $ path ,
6874 Composer $ composer ,
6975 ClassUtils $ class ,
7076 LoggerInterface $ logger ,
7177 IndexProcessor $ processor ,
78+ EventDispatcher $ dispatcher ,
7279 $ verbose = false
73- )
74- {
80+ ) {
7581 $ this ->path = $ path ;
7682 $ this ->composer = $ composer ;
7783 $ this ->classUtils = $ class ;
7884 $ this ->logger = $ logger ;
7985 $ this ->plugins = array ();
8086 $ this ->verbose = $ verbose ;
8187 $ this ->processor = $ processor ;
88+ $ this ->dispatcher = $ dispatcher ;
8289 }
8390
8491 public function getComposerUtils (){
@@ -95,11 +102,16 @@ public function getNamespaceUtils(){
95102
96103 public function generateIndex (Project $ project )
97104 {
105+ $ event = new IndexGenerationEvent ($ project );
106+ $ this ->dispatcher ->dispatch (self ::BEFORE_GENERATION , $ event );
107+
98108 $ index = $ project ->getIndex ();
99109 $ this ->populateClassMapIndex ($ project );
100110
101111 $ this ->generateProjectIndex ($ index );
102112
113+ $ this ->dispatcher ->dispatch (self ::AFTER_GENERATION , $ event );
114+
103115 return $ index ;
104116 }
105117
0 commit comments