define() 공개 메소드

Sets a factory for the service creation. The same service will be returned every time
public define ( string $id, callable $definition, array $tags = [] )
$id string
$definition callable
$tags array
예제 #1
0
 private function registerCustomMatchers(IndexedServiceContainer $container, array $matchersClassnames)
 {
     foreach ($matchersClassnames as $class) {
         $this->ensureIsValidMatcherClass($class);
         $container->define(sprintf('matchers.%s', $class), function () use($class) {
             return new $class();
         }, ['matchers']);
     }
 }
예제 #2
0
 /**
  * @param IndexedServiceContainer $container
  */
 private function setupShutdown(IndexedServiceContainer $container)
 {
     $container->define('process.shutdown', function () {
         return new Shutdown();
     });
 }
예제 #3
0
 /**
  * @param IndexedServiceContainer $container
  */
 private function assembleHtmlPresenter(IndexedServiceContainer $container)
 {
     $container->define('formatter.presenter.html', function (IndexedServiceContainer $c) {
         return new SimplePresenter($c->get('formatter.presenter.value_presenter'), new SimpleExceptionPresenter($c->get('formatter.presenter.differ'), $c->get('formatter.presenter.html.exception_element_presenter'), new CallArgumentsPresenter($c->get('formatter.presenter.differ')), $c->get('formatter.presenter.html.exception.phpspec')));
     });
     $container->define('formatter.presenter.html.exception_element_presenter', function (IndexedServiceContainer $c) {
         return new SimpleExceptionElementPresenter($c->get('formatter.presenter.value.exception_type_presenter'), $c->get('formatter.presenter.value_presenter'));
     });
     $container->define('formatter.presenter.html.exception.phpspec', function () {
         return new HtmlPhpSpecExceptionPresenter();
     });
 }