Skip to content

Commit

Permalink
Remove proxy manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Lander Vanderstraeten committed Feb 8, 2018
1 parent 2e9c45a commit da216d1
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 46 deletions.
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"doctrine/collections": "~1.2",
"gitonomy/gitlib": "^1.0.3",
"monolog/monolog": "~1.16",
"ocramius/proxy-manager": "~0.4|~1.0|~2.0",
"seld/jsonlint": "~1.1",
"symfony/config": "~2.7|~3.0|~4.0",
"symfony/console": "~2.7|~3.0|~4.0",
Expand All @@ -20,7 +19,6 @@
"symfony/finder": "~2.7|~3.0|~4.0",
"symfony/options-resolver": "~2.7|~3.0|~4.0",
"symfony/process": "~2.7|~3.0|~4.0",
"symfony/proxy-manager-bridge": "~2.7|~3.0|~4.0",
"symfony/yaml": "~2.7|~3.0|~4.0"
},
"require-dev": {
Expand Down
1 change: 0 additions & 1 deletion resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ services:

grumphp.io.console:
class: GrumPHP\IO\ConsoleIO
lazy: true
arguments:
- '@console.input'
- '@console.output'
Expand Down
2 changes: 0 additions & 2 deletions src/Configuration/ContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace GrumPHP\Configuration;

use GrumPHP\Util\Filesystem;
use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
Expand All @@ -19,7 +18,6 @@ final class ContainerFactory
public static function buildFromConfiguration($path)
{
$container = new ContainerBuilder();
$container->setProxyInstantiator(new RuntimeInstantiator());

// Add compiler passes:
$container->addCompilerPass(new Compiler\ExtensionCompilerPass());
Expand Down
86 changes: 45 additions & 41 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use GrumPHP\Configuration\ContainerFactory;
use GrumPHP\Exception\RuntimeException;
use GrumPHP\IO\IOInterface;
use GrumPHP\IO\ConsoleIO;
use GrumPHP\Locator\ConfigurationFile;
use GrumPHP\Util\Composer;
use GrumPHP\Util\Filesystem;
Expand All @@ -14,6 +14,7 @@
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

Expand Down Expand Up @@ -42,9 +43,6 @@ class Application extends SymfonyConsole
*/
protected $composerHelper;

/**
* Set up application:
*/
public function __construct()
{
$this->filesystem = new Filesystem();
Expand Down Expand Up @@ -78,64 +76,64 @@ protected function getDefaultInputDefinition()
*/
protected function getDefaultCommands()
{
$container = $this->getContainer();
$commands = parent::getDefaultCommands();

$commands[] = new Command\ConfigureCommand(
$container->get('config'),
$container->get('grumphp.util.filesystem'),
$container->get('git.repository')
$this->container->get('config'),
$this->container->get('grumphp.util.filesystem'),
$this->container->get('git.repository')
);
$commands[] = new Command\RunCommand(
$container->get('config'),
$container->get('locator.registered_files')
$this->container->get('config'),
$this->container->get('locator.registered_files')
);

$commands[] = new Command\Git\CommitMsgCommand(
$container->get('config'),
$container->get('locator.changed_files'),
$container->get('grumphp.util.filesystem')
$this->container->get('config'),
$this->container->get('locator.changed_files'),
$this->container->get('grumphp.util.filesystem')
);
$commands[] = new Command\Git\DeInitCommand(
$container->get('config'),
$container->get('grumphp.util.filesystem')
$this->container->get('config'),
$this->container->get('grumphp.util.filesystem')
);
$commands[] = new Command\Git\InitCommand(
$container->get('config'),
$container->get('grumphp.util.filesystem'),
$container->get('process_builder')
$this->container->get('config'),
$this->container->get('grumphp.util.filesystem'),
$this->container->get('process_builder')
);
$commands[] = new Command\Git\PreCommitCommand(
$container->get('config'),
$container->get('locator.changed_files')
$this->container->get('config'),
$this->container->get('locator.changed_files')
);

return $commands;
}

/**
* {@inheritdoc}
*/
protected function getDefaultHelperSet()
{
$container = $this->getContainer();

$helperSet = parent::getDefaultHelperSet();
$helperSet->set($this->initializeComposerHelper());
$helperSet->set(new Helper\PathsHelper(
$container->get('config'),
$container->get('grumphp.util.filesystem'),
$container->get('locator.external_command'),
$this->container->get('config'),
$this->container->get('grumphp.util.filesystem'),
$this->container->get('locator.external_command'),
$this->getDefaultConfigPath()
));
$helperSet->set(new Helper\TaskRunnerHelper(
$container->get('config'),
$container->get('task_runner'),
$container->get('event_dispatcher')
$this->container->get('config'),
$this->container->get('task_runner'),
$this->container->get('event_dispatcher')
));

return $helperSet;
}

/**
* @return \Symfony\Component\DependencyInjection\ContainerBuilder
* @return ContainerBuilder
*/
protected function getContainer()
{
Expand All @@ -146,35 +144,30 @@ protected function getContainer()
// Load cli options:
$input = new ArgvInput();
$configPath = $input->getParameterOption(['--config', '-c'], $this->getDefaultConfigPath());
$output = new ConsoleOutput();

// Build the service container:
$this->container = ContainerFactory::buildFromConfiguration($configPath);
$this->container->set('console.input', $input);
$this->container->set('console.output', $output);

return $this->container;
}

/**
* Configure IO of GrumPHP objects
*
* @param InputInterface $input
* @param OutputInterface $output
* {@inheritdoc}
*/
protected function configureIO(InputInterface $input, OutputInterface $output)
{
parent::configureIO($input, $output);

$container = $this->getContainer();

// Register the console input and output to the container
$container->set('console.input', $input);
$container->set('console.output', $output);
/** @var ConsoleIO $io */
$io = $this->container->get('grumphp.io.console');

// Redirect the GrumPHP logger to the stdout in verbose mode
/** @var IOInterface $io */
$io = $container->get('grumphp.io.console');
if ($io->isVerbose()) {
/** @var Logger $logger */
$logger = $container->get('grumphp.logger');
$logger = $this->container->get('grumphp.logger');
$logger->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));
}
}
Expand Down Expand Up @@ -218,4 +211,15 @@ protected function initializeComposerHelper()

return $this->composerHelper = new Helper\ComposerHelper($configuration, $rootPackage);
}

/**
* {@inheritdoc}
*/
public function run(InputInterface $input = null, OutputInterface $output = null)
{
/** @var ConsoleIO $io */
$io = $this->container->get('grumphp.io.console');

return parent::run($io->getInput(), $io->getOutput());
}
}
16 changes: 16 additions & 0 deletions src/IO/ConsoleIO.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ public function writeError($messages, $newline = true)
$this->doWrite($messages, $newline, true);
}

/**
* @return InputInterface
*/
public function getInput()
{
return $this->input;
}

/**
* @return OutputInterface
*/
public function getOutput()
{
return $this->output;
}

/**
* @param resource $handle
*
Expand Down

0 comments on commit da216d1

Please sign in to comment.