예제 #1
0
 /**
  * @return ObjectDefinition
  */
 protected function getRouter()
 {
     $router = new ObjectDefinition(RouteCollection::class);
     $router->setConstructorArguments($this->container);
     $router->addMethodCall('setStrategy', new Reference(StrategyInterface::class));
     return $router;
 }
예제 #2
0
 /**
  * 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 getMountManager()
 {
     $mountManager = new ObjectDefinition(MountManager::class);
     $mountManager->setConstructorArguments(array_map(function (AdapterInterface $adapter) {
         return new Filesystem($adapter);
     }, $this->adapters));
     return $mountManager;
 }
예제 #5
0
 /**
  * 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)];
 }
예제 #6
0
 /**
  * {@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];
 }
예제 #7
0
 /**
  * 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)];
 }
예제 #8
0
 /**
  * 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)];
 }
예제 #9
0
 /**
  * @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;
 }
예제 #10
0
 /**
  * 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 getHandlerMiddleware()
 {
     $middleware = new ObjectDefinition(CommandHandlerMiddleware::class);
     $middleware->setConstructorArguments(new Reference(CommandNameExtractor::class), new Reference(HandlerLocator::class), new Reference(MethodNameInflector::class));
     return $middleware;
 }
예제 #12
0
 /**
  * @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;
 }