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