set() public method

Sets a object to be used as a service
public set ( string $id, object $service, array $tags = [] )
$id string
$service object
$tags array
Esempio n. 1
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $helperSet = $this->getHelperSet();
     $this->container->set('console.input', $input);
     $this->container->set('console.output', $output);
     $this->container->setShared('console.prompter.factory', function ($c) use($helperSet) {
         return new Factory($c->get('console.input'), $c->get('console.output'), $helperSet);
     });
     $this->container->setShared('process.executioncontext', function () {
         return JsonExecutionContext::fromEnv($_SERVER);
     });
     $assembler = new ContainerAssembler();
     $assembler->build($this->container);
     $this->loadConfigurationFile($input, $this->container);
     foreach ($this->container->getByPrefix('console.commands') as $command) {
         $this->add($command);
     }
     $this->setDispatcher($this->container->get('console_event_dispatcher'));
     $this->container->get('console.io')->setConsoleWidth($this->getTerminalWidth());
     StreamWrapper::reset();
     foreach ($this->container->getByPrefix('loader.resource_loader.spec_transformer') as $transformer) {
         StreamWrapper::addTransformer($transformer);
     }
     StreamWrapper::register();
     return parent::doRun($input, $output);
 }
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     $container->set('code_generator.generators.method.classidentifier', function ($c) {
         return new ClassIdentifier();
     });
     $container->set('code_generator.generators.method.argumentbuilder', function ($c) {
         return new StringBuilder($c->get('code_generator.generators.method.classidentifier'));
     });
     $container->set('code_generator.generators.method', function ($c) {
         return new TypeHintedMethodGenerator($c->get('console.io'), $c->get('code_generator.templates'), null, $c->get('code_generator.generators.method.argumentbuilder'));
     });
 }
Esempio n. 3
0
 /**
  * @param ServiceContainer $container
  */
 private function assembleDifferEngines(ServiceContainer $container)
 {
     $container->set('formatter.presenter.differ.engines.string', function () {
         return new StringEngine();
     });
     $container->set('formatter.presenter.differ.engines.array', function () {
         return new ArrayEngine();
     });
     $container->set('formatter.presenter.differ.engines.object', function (ServiceContainer $c) {
         return new ObjectEngine(new Exporter(), $c->get('formatter.presenter.differ.engines.string'));
     });
 }
Esempio n. 4
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $this->container->set('console.input', $input);
     $this->container->set('console.output', $output);
     $this->container->set('console.helper.dialog', $this->getHelperSet()->get('dialog'));
     $assembler = new ContainerAssembler();
     $assembler->build($this->container);
     $this->loadConfigurationFile($input, $this->container);
     foreach ($this->container->getByPrefix('console.commands') as $command) {
         $this->add($command);
     }
     return parent::doRun($input, $output);
 }
 /**
  * Add a formatter to the service container
  *
  * @param ServiceContainer $container
  * @param string           $name
  * @param string           $class
  */
 protected function addFormatter(ServiceContainer $container, $name, $class)
 {
     $container->set('formatter.formatters.teamcity', function ($c) use($class) {
         /** @var ServiceContainer $c */
         return new $class($c->get('formatter.presenter'), $c->get('console.io'), $c->get('event_dispatcher.listeners.stats'));
     });
 }
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     $container->setShared('event_dispatcher.listeners.data_provider', function ($c) {
         return new DataProviderListener();
     });
     $container->set('runner.maintainers.data_provider', function ($c) {
         return new DataProviderMaintainer();
     });
 }
 /**
  * @return PhpGuardExtension
  */
 private function getExtension()
 {
     $runner = new \PhpGuard\Application\Bridge\CodeCoverage\CodeCoverageSession();
     $container = new ServiceContainer();
     $container->set('coverage.session', $runner);
     $extension = new PhpGuardExtension();
     $extension->load($container);
     return $extension;
 }
Esempio n. 8
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $helperSet = $this->getHelperSet();
     $this->container->set('console.input', $input);
     $this->container->set('console.output', $output);
     $this->container->setShared('console.prompter.factory', function ($c) use($helperSet) {
         return new Factory($c->get('console.input'), $c->get('console.output'), $helperSet);
     });
     $assembler = new ContainerAssembler();
     $assembler->build($this->container);
     $this->loadConfigurationFile($input, $this->container);
     foreach ($this->container->getByPrefix('console.commands') as $command) {
         $this->add($command);
     }
     $this->setDispatcher($this->container->get('console_event_dispatcher'));
     $this->container->get('console.io')->setConsoleWidth($this->getTerminalWidth());
     return parent::doRun($input, $output);
 }
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     $container->set('matchers.rest_view', function (ServiceContainer $c) {
         /** @var PresenterInterface $presenter */
         $presenter = $c->get('formatter.presenter');
         $matcher = new SimpleFactory();
         return new RestViewMatcher($presenter, $matcher);
     });
 }
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     $container->set('runner.maintainers.configuration_loaded_extensions', function (ServiceContainer $c) {
         $config = $c->getParam('matchers', []);
         $presenter = $c->get('formatter.presenter');
         $instances = $this->createInstances($config);
         $matchers = $this->resolveMatchers($instances, $presenter);
         return new MatchersLoaderMaintainer($matchers);
     });
 }
 public function load(ServiceContainer $container)
 {
     $container->set('runner.maintainers.initialise_magento_object_factory', function ($c) {
         return new Runner\Maintainer\BootstrapMaintainer();
     });
 }
 /**
  * @param ServiceContainer $container
  * @param GeneratorInterface $generator
  */
 private function decorateGenerator(ServiceContainer $container, $key, GeneratorInterface $generator)
 {
     $container->set($key, function (ServiceContainer $c) use($generator) {
         return new GitAddingGenerator($generator, $c->get('phpspec_extension.git.repository'), new Filesystem());
     });
 }
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     $container->set('runner.maintainers.string_pattern_matcher_maintainer', function ($c) {
         return new StringPatternMatcherMaintainer();
     });
 }
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     $container->set('formatter.formatters.emoji', function ($c) {
         return new EmojiFormatter($c->get('console.io'));
     });
 }
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     $container->set('event_dispatcher.listeners.spec_mapper', function ($c) {
         return new SpecMapperListener(new JsonSpecMapLogger($c->getParam('humbug.spec_mapper.target')));
     });
 }
 public function load(ServiceContainer $container)
 {
     $container->set('formatter.formatters.teamcity', function (ServiceContainer $container) {
         return new Formatter($container->get('formatter.presenter'), $container->get('console.io'), $container->get('event_dispatcher.listeners.stats'));
     });
 }
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     $container->set('matchers.be_odd', function (ServiceContainer $c) {
         return new BeOddMatcher($c->get('formatter.presenter'));
     });
 }
 function it_should_register_matcher(ServiceContainer $container)
 {
     $container->set('matchers.rest_view', Argument::type(\Closure::class))->shouldBeCalled();
     $this->load($container);
 }
 function it_registers_TeamCity_formatter_when_loaded(ServiceContainer $container)
 {
     $container->set('formatter.formatters.teamcity', Argument::type('Closure'))->shouldBeCalled();
     $this->load($container);
 }
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     $container->set('event_dispatcher.listeners.free_memory', function ($c) {
         return new FreeMemoryListener();
     });
 }
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     $container->set('runner.maintainers.prepare_before', function ($c) {
         return new BeforeMaintainer($c->get('unwrapper'));
     });
 }
Esempio n. 22
0
 /**
  * @param ServiceContainer $container
  */
 protected function setupRunner(ServiceContainer $container)
 {
     $container->setShared('runner.suite', function ($c) {
         return new Runner\SuiteRunner($c->get('event_dispatcher'), $c->get('runner.specification'));
     });
     $container->setShared('runner.specification', function ($c) {
         return new Runner\SpecificationRunner($c->get('event_dispatcher'), $c->get('runner.example'));
     });
     $container->setShared('runner.example', function ($c) {
         $runner = new Runner\ExampleRunner($c->get('event_dispatcher'), $c->get('formatter.presenter'));
         array_map(array($runner, 'registerMaintainer'), $c->getByPrefix('runner.maintainers'));
         return $runner;
     });
     $container->set('runner.maintainers.errors', function ($c) {
         return new Runner\Maintainer\ErrorMaintainer($c->getParam('runner.maintainers.errors.level', E_ALL ^ E_STRICT));
     });
     $container->set('runner.maintainers.collaborators', function ($c) {
         return new Runner\Maintainer\CollaboratorsMaintainer($c->get('unwrapper'));
     });
     $container->set('runner.maintainers.let_letgo', function ($c) {
         return new Runner\Maintainer\LetAndLetgoMaintainer();
     });
     $container->set('runner.maintainers.matchers', function ($c) {
         return new Runner\Maintainer\MatchersMaintainer($c->get('formatter.presenter'), $c->get('unwrapper'));
     });
     $container->set('runner.maintainers.subject', function ($c) {
         return new Runner\Maintainer\SubjectMaintainer($c->get('formatter.presenter'), $c->get('unwrapper'), $c->get('event_dispatcher'));
     });
     $container->setShared('unwrapper', function ($c) {
         return new Wrapper\Unwrapper();
     });
 }
Esempio n. 23
0
 /**
  * @param ServiceContainer $container
  */
 private function setupMatchers(ServiceContainer $container)
 {
     $container->set('matchers.identity', function (ServiceContainer $c) {
         return new Matcher\IdentityMatcher($c->get('formatter.presenter'));
     });
     $container->set('matchers.comparison', function (ServiceContainer $c) {
         return new Matcher\ComparisonMatcher($c->get('formatter.presenter'));
     });
     $container->set('matchers.throwm', function (ServiceContainer $c) {
         return new Matcher\ThrowMatcher($c->get('unwrapper'), $c->get('formatter.presenter'));
     });
     $container->set('matchers.type', function (ServiceContainer $c) {
         return new Matcher\TypeMatcher($c->get('formatter.presenter'));
     });
     $container->set('matchers.object_state', function (ServiceContainer $c) {
         return new Matcher\ObjectStateMatcher($c->get('formatter.presenter'));
     });
     $container->set('matchers.scalar', function (ServiceContainer $c) {
         return new Matcher\ScalarMatcher($c->get('formatter.presenter'));
     });
     $container->set('matchers.array_count', function (ServiceContainer $c) {
         return new Matcher\ArrayCountMatcher($c->get('formatter.presenter'));
     });
     $container->set('matchers.array_key', function (ServiceContainer $c) {
         return new Matcher\ArrayKeyMatcher($c->get('formatter.presenter'));
     });
     $container->set('matchers.array_key_with_value', function (ServiceContainer $c) {
         return new Matcher\ArrayKeyValueMatcher($c->get('formatter.presenter'));
     });
     $container->set('matchers.array_contain', function (ServiceContainer $c) {
         return new Matcher\ArrayContainMatcher($c->get('formatter.presenter'));
     });
     $container->set('matchers.string_start', function (ServiceContainer $c) {
         return new Matcher\StringStartMatcher($c->get('formatter.presenter'));
     });
     $container->set('matchers.string_end', function (ServiceContainer $c) {
         return new Matcher\StringEndMatcher($c->get('formatter.presenter'));
     });
     $container->set('matchers.string_regex', function (ServiceContainer $c) {
         return new Matcher\StringRegexMatcher($c->get('formatter.presenter'));
     });
     $container->set('matchers.string_contain', function (ServiceContainer $c) {
         return new Matcher\StringContainMatcher($c->get('formatter.presenter'));
     });
 }
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     $container->set('matchers.value', function (ServiceContainer $c) {
         return new ValueMatcher($c->get('formatter.presenter'));
     });
 }
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     $container->set('event_dispatcher.listeners.time_collector', function ($c) {
         return new TimeCollectorListener(new JsonTimeLogger($c->getParam('humbug.time_collector.target')));
     });
 }
 private function setupMatchers(ServiceContainer $container)
 {
     $container->set('matcher_manager', function (ServiceContainer $c) {
         $matchers = new MatcherManager($c->get('formatter.presenter'));
         array_map(array($matchers, 'add'), $c->getByPrefix('matchers.matcher'));
         return $matchers;
     });
     $container->setShared('matchers.matcher.identity', function (ServiceContainer $c) {
         return new Matcher\IdentityMatcher($c->get('formatter.presenter'));
     });
     $container->setShared('matchers.matcher.comparison', function (ServiceContainer $c) {
         return new Matcher\ComparisonMatcher($c->get('formatter.presenter'));
     });
     $container->setShared('matchers.matcher.throw', function (ServiceContainer $c) {
         return new Matcher\ThrowMatcher($c->get('unwrapper'), $c->get('formatter.presenter'));
     });
     $container->setShared('matchers.matcher.type', function (ServiceContainer $c) {
         return new Matcher\TypeMatcher($c->get('formatter.presenter'));
     });
     $container->setShared('matchers.matcher.object_state', function (ServiceContainer $c) {
         return new Matcher\ObjectStateMatcher($c->get('formatter.presenter'));
     });
     $container->setShared('matchers.matcher.scalar', function (ServiceContainer $c) {
         return new Matcher\ScalarMatcher($c->get('formatter.presenter'));
     });
     $container->setShared('matchers.matcher.array_count', function (ServiceContainer $c) {
         return new Matcher\ArrayCountMatcher($c->get('formatter.presenter'));
     });
     $container->setShared('matchers.matcher.array_key', function (ServiceContainer $c) {
         return new Matcher\ArrayKeyMatcher($c->get('formatter.presenter'));
     });
     $container->setShared('matchers.matcher.array_contain', function (ServiceContainer $c) {
         return new Matcher\ArrayContainMatcher($c->get('formatter.presenter'));
     });
     $container->setShared('matchers.matcher.string_start', function (ServiceContainer $c) {
         return new Matcher\StringStartMatcher($c->get('formatter.presenter'));
     });
     $container->setShared('matchers.matcher.string_end', function (ServiceContainer $c) {
         return new Matcher\StringEndMatcher($c->get('formatter.presenter'));
     });
     $container->setShared('matchers.matcher.string_regex', function (ServiceContainer $c) {
         return new Matcher\StringRegexMatcher($c->get('formatter.presenter'));
     });
 }