public function createService(ServiceManager $serviceManager) { $viewConfig = $serviceManager->getServiceConfig('view', array()); $templateDir = isset($viewConfig['template_dir']) ? $viewConfig['template_dir'] : $this->templateDir; $compileDir = isset($viewConfig['compile_dir']) ? $viewConfig['compile_dir'] : $this->compileDir; return new View($templateDir, $compileDir); }
public function configureServiceManager(ServiceManager $serviceManager) { $serviceConfig = $serviceManager->getServiceConfig('services', array()); $serviceConfig = array_merge($this->defaultServiceConfig, $serviceConfig); foreach ($serviceConfig as $serviceName => $serviceFactoryName) { $serviceManager->registerService($serviceName, $serviceFactoryName); } }
public function createService(ServiceManager $serviceManager) { $localeConfig = $serviceManager->getServiceConfig('locale', array()); $path = isset($localeConfig['path']) ? $localeConfig['path'] : $this->path; $lang = isset($_COOKIE['lang']) ? $_COOKIE['lang'] : (isset($localeConfig['lang']) ? $localeConfig['lang'] : $this->lang); $locale = new Locale(); $locale->setPath($path); $locale->setLang($lang); return $locale; }
public function createService(ServiceManager $serviceManager) { $listeners = $serviceManager->getServiceConfig('listeners', array()); $listeners = array_merge($this->defaultListeners, $listeners); $eventManager = new EventManager(); foreach ($listeners as $listener) { $eventManager->attach(new $listener()); } return $eventManager; }
public function createService(ServiceManager $serviceManager) { $config = $serviceManager->getServiceConfig('router'); $routeClass = isset($config['class']) ? $config['class'] : $this->routeClass; if (!class_exists($routeClass)) { throw new \Exception(sprintf("Route class '%s' not found.", $routeClass)); } $route = new $routeClass(); if (!$route instanceof RouteInterface) { throw new \Exception(sprintf("Route class '%s' must implements '%s'.", $routeClass, 'Frame\\Route\\RouteInterface')); } $default = isset($config['default']) ? $config['default'] : $this->default; $router = new Router($route, $default); return $router; }
public function createService(ServiceManager $serviceManager) { $curlConfig = $serviceManager->getServiceConfig('curl'); $baseUrl = isset($curlConfig['base_url']) ? $curlConfig['base_url'] : ''; return new Curl($baseUrl); }