/** * Returns the definition to register in the container. * * @return DefinitionInterface[] */ public function getDefinitions() { $handler = new CommandHandlerMiddleware(new ClassNameExtractor(), new ContainerLocator($this->container), new HandleInflector()); $bus = new ObjectDefinition(CommandBus::class); $bus->setConstructorArguments([$handler]); return [CommandBus::class => $bus, 'bus' => new Reference(CommandBus::class)]; }
/** * @return ObjectDefinition */ protected function getLogger() { $logger = new ObjectDefinition(Logger::class); $logger->setConstructorArguments('logs'); $logger->addMethodCall('pushHandler', new Reference(HandlerInterface::class)); return $logger; }
/** * @return ObjectDefinition */ protected function getRouter() { $router = new ObjectDefinition(RouteCollection::class); $router->setConstructorArguments($this->container); $router->addMethodCall('setStrategy', new Reference(StrategyInterface::class)); return $router; }
/** * @return ObjectDefinition */ protected function getMountManager() { $mountManager = new ObjectDefinition(MountManager::class); $mountManager->setConstructorArguments(array_map(function (AdapterInterface $adapter) { return new Filesystem($adapter); }, $this->adapters)); return $mountManager; }
/** * Returns the definition to register in the container. * * @return DefinitionInterface[] */ public function getDefinitions() { $handler = new ObjectDefinition(StreamHandler::class); $handler->setConstructorArguments($this->path . DS . $this->filename, Logger::WARNING); $logger = new ObjectDefinition(Logger::class); $logger->setConstructorArguments('glue'); $logger->addMethodCall('pushHandler', new Reference(HandlerInterface::class)); return [LoggerInterface::class => $logger, HandlerInterface::class => $handler, 'monolog' => new Reference(LoggerInterface::class)]; }
/** * Returns the definition to register in the container. * * @return DefinitionInterface[] */ public function getDefinitions() { $mountManager = new ObjectDefinition(MountManager::class); $mountManager->setConstructorArguments(array_map(function (AdapterInterface $adapter) { return new Filesystem($adapter); }, $this->adapters)); $default = new FactoryCallDefinition(new Reference('flysystem.mount-manager'), 'getFilesystem'); $default->setArguments($this->default); return [MountManager::class => $mountManager, FilesystemInterface::class => $default, 'flysystem.mount-manager' => new Reference(MountManager::class), 'flysystem' => new Reference(FilesystemInterface::class)]; }
/** * {@inheritdoc} */ public function getDefinitions() { // Cancel if no factories if (!is_dir($this->path)) { return []; } $factory = new ObjectDefinition(Factory::class); $factory->addMethodCall('loadFactories', $this->path); return [Factory::class => $factory]; }
/** * Returns the definition to register in the container. * * @return DefinitionInterface[] */ public function getDefinitions() { $manager = new ObjectDefinition(Manager::class); foreach ($this->connections as $name => $connection) { $manager->addMethodCall('addConnection', $connection, $name); } $manager->addMethodCall('bootEloquent'); $manager->addMethodCall('setAsGlobal'); return [Manager::class => $manager]; }
/** * @return ObjectDefinition */ protected function getDatabaseManager() { $manager = new ObjectDefinition(Manager::class); foreach ($this->connections as $name => $connection) { $manager->addMethodCall('addConnection', $connection, $name); } $manager->addMethodCall('bootEloquent'); $manager->addMethodCall('setAsGlobal'); return $manager; }
/** * Returns the definition to register in the container. * * @return DefinitionInterface[] */ public function getDefinitions() { $relayFactory = new ObjectDefinition(RelayBuilder::class); $relayFactory->setConstructorArguments(function ($callable) { return is_string($callable) ? $this->container->get($callable) : $callable; }); $relay = new FactoryCallDefinition(new Reference(RelayBuilder::class), 'newInstance'); $relay->setArguments($this->middlewares); return [RelayBuilder::class => $relayFactory, Relay::class => $relay, 'pipeline' => new Reference(Relay::class)]; }
/** * @return ObjectDefinition */ protected function getEnvironment() { $twig = new ObjectDefinition(Twig_Environment::class); $twig->setConstructorArguments(new Reference(Twig_LoaderInterface::class), $this->options); foreach ($this->extensions as $extension) { $extension = is_string($extension) ? new Reference($extension) : $extension; $twig->addMethodCall('addExtension', $extension); } return $twig; }
/** * {@inheritdoc} */ public function getDefinitions() { $generator = new ObjectDefinition(UrlGenerator::class); $generator->setConstructorArguments($this->namespace, new Reference('routes')); $function = new ExtendDefinition(Twig_Environment::class); $function->addMethodCall('addFunction', new Twig_SimpleFunction('url', function ($action, $parameters = []) { return $this->container->get(UrlGenerator::class)->to($action, $parameters); })); return [UrlGenerator::class => $generator, $function]; }
/** * Returns the definition to register in the container. * * @return DefinitionInterface[] */ public function getDefinitions() { $console = new ObjectDefinition(Application::class); $console->addMethodCall('setName', 'Glue'); $console->addMethodCall('setVersion', Glue::VERSION); // Register commands foreach ($this->commands as $command) { $console->addMethodCall('add', new Reference($command)); } return [Application::class => $console, 'console' => new Reference(Application::class)]; }
/** * {@inheritdoc} */ public function getDefinitions() { $emitter = new ObjectDefinition(Emitter::class); foreach ($this->listeners as $event => $listeners) { $listeners = (array) $listeners; foreach ($listeners as $listener) { $emitter->addMethodCall('addListener', $event, $listener); } } return [Emitter::class => $emitter]; }
/** * @return ObjectDefinition */ protected function getApplication() { $console = new ObjectDefinition(Application::class); $console->addMethodCall('setName', $this->name); $console->addMethodCall('setVersion', $this->version); // Register commands foreach ($this->commands as $command) { $command = is_string($command) ? new Reference($command) : $command; $console->addMethodCall('add', $command); } return $console; }
/** * Returns the definition to register in the container. * * @return DefinitionInterface[] */ public function getDefinitions() { $isViewsFolder = is_string($this->views) && is_dir($this->views); // Define loader $loader = $isViewsFolder ? Twig_Loader_Filesystem::class : Twig_Loader_Array::class; $loader = new ObjectDefinition($loader); $loader->setConstructorArguments($this->views ?: []); $twig = new ObjectDefinition(Twig_Environment::class); $twig->setConstructorArguments(new Reference(Twig_LoaderInterface::class), $this->options); foreach ($this->extensions as $extension) { $twig->addMethodCall('addExtension', new Reference($extension)); } return [Twig_LoaderInterface::class => $loader, Twig_Environment::class => $twig, 'twig' => new Reference(Twig_Environment::class)]; }
/** * @return ObjectDefinition */ protected function getFactory() { $relayFactory = new ObjectDefinition(RelayBuilder::class); $relayFactory->setConstructorArguments([$this, 'resolve']); return $relayFactory; }
/** * @return ObjectDefinition */ protected function getRepository() { $repository = new ObjectDefinition(Repository::class); $repository->setConstructorArguments(new Reference(Store::class)); return $repository; }
/** * @return ObjectDefinition */ protected function getHandlerMiddleware() { $middleware = new ObjectDefinition(CommandHandlerMiddleware::class); $middleware->setConstructorArguments(new Reference(CommandNameExtractor::class), new Reference(HandlerLocator::class), new Reference(MethodNameInflector::class)); return $middleware; }
/** * {@inheritdoc} */ public function getDefinitions() { $locator = new ObjectDefinition(ContainerLocator::class); $locator->addMethodCall('setContainer', $this->container); return [HandlerLocator::class => $locator]; }