|
19 | 19 | use PhpSchool\PhpWorkshop\CodePatcher; |
20 | 20 | use PhpSchool\PhpWorkshop\Event\EventDispatcher; |
21 | 21 | use PhpSchool\PhpWorkshop\ExerciseDispatcher; |
| 22 | +use PhpSchool\PhpWorkshop\ExerciseRunner\Factory\CgiRunnerFactory; |
| 23 | +use PhpSchool\PhpWorkshop\ExerciseRunner\Factory\CliRunnerFactory; |
| 24 | +use PhpSchool\PhpWorkshop\ExerciseRunner\RunnerManager; |
22 | 25 | use PhpSchool\PhpWorkshop\Factory\EventDispatcherFactory; |
23 | 26 | use PhpSchool\PhpWorkshop\Factory\MenuFactory; |
24 | 27 | use PhpSchool\PhpWorkshop\Factory\ResultRendererFactory; |
25 | | -use PhpSchool\PhpWorkshop\Factory\RunnerFactory; |
26 | 28 | use PhpSchool\PhpWorkshop\Listener\CheckExerciseAssignedListener; |
27 | 29 | use PhpSchool\PhpWorkshop\Listener\CodePatchListener; |
| 30 | +use PhpSchool\PhpWorkshop\Listener\ConfigureCommandListener; |
28 | 31 | use PhpSchool\PhpWorkshop\Listener\PrepareSolutionListener; |
29 | 32 | use PhpSchool\PhpWorkshop\Listener\SelfCheckListener; |
30 | 33 | use PhpSchool\PhpWorkshop\MenuItem\ResetProgress; |
|
62 | 65 | WorkshopType::class => WorkshopType::STANDARD(), |
63 | 66 | ExerciseDispatcher::class => function (ContainerInterface $c) { |
64 | 67 | return new ExerciseDispatcher( |
65 | | - $c->get(RunnerFactory::class), |
| 68 | + $c->get(RunnerManager::class), |
66 | 69 | $c->get(ResultAggregator::class), |
67 | 70 | $c->get(EventDispatcher::class), |
68 | 71 | $c->get(CheckRepository::class) |
|
85 | 88 | new CommandDefinition('menu', [], MenuCommand::class), |
86 | 89 | new CommandDefinition('help', [], HelpCommand::class), |
87 | 90 | new CommandDefinition('print', [], PrintCommand::class), |
88 | | - new CommandDefinition('verify', ['program'], VerifyCommand::class), |
89 | | - new CommandDefinition('run', ['program'], RunCommand::class), |
| 91 | + new CommandDefinition('verify', [], VerifyCommand::class), |
| 92 | + new CommandDefinition('run', [], RunCommand::class), |
90 | 93 | new CommandDefinition('credits', [], CreditsCommand::class) |
91 | 94 | ], |
92 | 95 | 'menu', |
|
116 | 119 | EventDispatcherFactory::class => object(), |
117 | 120 |
|
118 | 121 | //Exercise Runners |
119 | | - RunnerFactory::class => object(), |
| 122 | + RunnerManager::class => function (ContainerInterface $c) { |
| 123 | + $manager = new RunnerManager; |
| 124 | + $manager->addFactory(new CliRunnerFactory($c->get(EventDispatcher::class))); |
| 125 | + $manager->addFactory(new CgiRunnerFactory($c->get(EventDispatcher::class))); |
| 126 | + return $manager; |
| 127 | + }, |
120 | 128 |
|
121 | 129 | //commands |
122 | 130 | MenuCommand::class => function (ContainerInterface $c) { |
|
171 | 179 | }, |
172 | 180 |
|
173 | 181 | //Listeners |
174 | | - PrepareSolutionListener::class => object(), |
175 | | - CodePatchListener::class => function (ContainerInterface $c) { |
| 182 | + PrepareSolutionListener::class => object(), |
| 183 | + CodePatchListener::class => function (ContainerInterface $c) { |
176 | 184 | return new CodePatchListener($c->get(CodePatcher::class)); |
177 | 185 | }, |
178 | | - SelfCheckListener::class => function (ContainerInterface $c) { |
| 186 | + SelfCheckListener::class => function (ContainerInterface $c) { |
179 | 187 | return new SelfCheckListener($c->get(ResultAggregator::class)); |
180 | 188 | }, |
181 | 189 | CheckExerciseAssignedListener::class => function (ContainerInterface $c) { |
182 | 190 | return new CheckExerciseAssignedListener($c->get(UserState::class)); |
183 | 191 | }, |
| 192 | + ConfigureCommandListener::class => function (ContainerInterface $c) { |
| 193 | + return new ConfigureCommandListener( |
| 194 | + $c->get(UserState::class), |
| 195 | + $c->get(ExerciseRepository::class), |
| 196 | + $c->get(RunnerManager::class) |
| 197 | + ); |
| 198 | + }, |
184 | 199 |
|
185 | 200 | //checks |
186 | 201 | FileExistsCheck::class => object(), |
|
266 | 281 | 'appContributors' => [], |
267 | 282 | 'eventListeners' => [ |
268 | 283 | 'route.pre.resolve.args' => [ |
269 | | - CheckExerciseAssignedListener::class |
| 284 | + CheckExerciseAssignedListener::class, |
| 285 | + ConfigureCommandListener::class, |
270 | 286 | ], |
271 | 287 | ] |
272 | 288 | ]; |
0 commit comments