PhpSpec\ServiceContainer\IndexedServiceContainer::define PHP Метод

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
    public function define($id, callable $definition, $tags = [])
    {
        $this->definitions[$id] = $definition;
        unset($this->services[$id]);
        $this->indexTags($id, $tags);
    }

Usage Example

Пример #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']);
     }
 }
All Usage Examples Of PhpSpec\ServiceContainer\IndexedServiceContainer::define