Skip to content

Runners configure commands #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 25, 2016
Merged
36 changes: 28 additions & 8 deletions app/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@
use PhpSchool\PhpWorkshop\CodePatcher;
use PhpSchool\PhpWorkshop\Event\EventDispatcher;
use PhpSchool\PhpWorkshop\ExerciseDispatcher;
use PhpSchool\PhpWorkshop\ExerciseRunner\Factory\CgiRunnerFactory;
use PhpSchool\PhpWorkshop\ExerciseRunner\Factory\CliRunnerFactory;
use PhpSchool\PhpWorkshop\ExerciseRunner\RunnerManager;
use PhpSchool\PhpWorkshop\Factory\EventDispatcherFactory;
use PhpSchool\PhpWorkshop\Factory\MenuFactory;
use PhpSchool\PhpWorkshop\Factory\ResultRendererFactory;
use PhpSchool\PhpWorkshop\Factory\RunnerFactory;
use PhpSchool\PhpWorkshop\Listener\CheckExerciseAssignedListener;
use PhpSchool\PhpWorkshop\Listener\CodePatchListener;
use PhpSchool\PhpWorkshop\Listener\ConfigureCommandListener;
use PhpSchool\PhpWorkshop\Listener\PrepareSolutionListener;
use PhpSchool\PhpWorkshop\Listener\SelfCheckListener;
use PhpSchool\PhpWorkshop\MenuItem\ResetProgress;
Expand Down Expand Up @@ -63,7 +66,7 @@
WorkshopType::class => WorkshopType::STANDARD(),
ExerciseDispatcher::class => function (ContainerInterface $c) {
return new ExerciseDispatcher(
$c->get(RunnerFactory::class),
$c->get(RunnerManager::class),
$c->get(ResultAggregator::class),
$c->get(EventDispatcher::class),
$c->get(CheckRepository::class)
Expand All @@ -86,8 +89,8 @@
new CommandDefinition('menu', [], MenuCommand::class),
new CommandDefinition('help', [], HelpCommand::class),
new CommandDefinition('print', [], PrintCommand::class),
new CommandDefinition('verify', ['program'], VerifyCommand::class),
new CommandDefinition('run', ['program'], RunCommand::class),
new CommandDefinition('verify', [], VerifyCommand::class),
new CommandDefinition('run', [], RunCommand::class),
new CommandDefinition('credits', [], CreditsCommand::class)
],
'menu',
Expand Down Expand Up @@ -117,7 +120,12 @@
EventDispatcherFactory::class => object(),

//Exercise Runners
RunnerFactory::class => object(),
RunnerManager::class => function (ContainerInterface $c) {
$manager = new RunnerManager;
$manager->addFactory(new CliRunnerFactory($c->get(EventDispatcher::class)));
$manager->addFactory(new CgiRunnerFactory($c->get(EventDispatcher::class)));
return $manager;
},

//commands
MenuCommand::class => function (ContainerInterface $c) {
Expand Down Expand Up @@ -172,16 +180,23 @@
},

//Listeners
PrepareSolutionListener::class => object(),
CodePatchListener::class => function (ContainerInterface $c) {
PrepareSolutionListener::class => object(),
CodePatchListener::class => function (ContainerInterface $c) {
return new CodePatchListener($c->get(CodePatcher::class));
},
SelfCheckListener::class => function (ContainerInterface $c) {
SelfCheckListener::class => function (ContainerInterface $c) {
return new SelfCheckListener($c->get(ResultAggregator::class));
},
CheckExerciseAssignedListener::class => function (ContainerInterface $c) {
return new CheckExerciseAssignedListener($c->get(UserState::class));
},
ConfigureCommandListener::class => function (ContainerInterface $c) {
return new ConfigureCommandListener(
$c->get(UserState::class),
$c->get(ExerciseRepository::class),
$c->get(RunnerManager::class)
);
},

//checks
FileExistsCheck::class => object(),
Expand Down Expand Up @@ -271,6 +286,11 @@
containerListener(CheckExerciseAssignedListener::class)
],
],
'configure-command-arguments' => [
'route.pre.resolve.args' => [
containerListener(ConfigureCommandListener::class)
],
],
'prepare-solution' => [
'verify.start' => [
containerListener(PrepareSolutionListener::class),
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
"nikic/php-parser": "^2.1"
},
"require-dev": {
"composer/composer": "^1.0-alpha",
"phpunit/phpunit": "^5.4",
"composer/composer": "^1.2",
"phpunit/phpunit": "^5.6",
"phpunit/phpunit-mock-objects": "^3.3",
"squizlabs/php_codesniffer": "^2.4"
},
"autoload" : {
Expand Down
Loading