/** * Runtime initializations based on the application specification. * Derived classes can override this method to provide additional initializations. */ protected function init() { foreach ($this->preload as $namespace) { using($namespace); } $locatorClass = $this->handlers['locator']; $parserClass = $this->handlers['parser']; $cacheClass = $this->handlers['cache']; $errorClass = $this->handlers['error']; $requestClass = $this->handlers['request']; $sessionClass = $this->handlers['session']; $vsmClass = $this->handlers['vsmanager']; $globalizationClass = $this->handlers['globalization']; $serviceManagerClass = $this->handlers['services']; $this->resourceLocator = new $locatorClass($this->specification->locator); $this->resourceParser = new $parserClass($this->specification->parser); $this->cacheManager = new $cacheClass($this->specification->cache); $this->errorHandler = new $errorClass($this->specification->error); $this->request = new $requestClass($this->specification->request); $this->session = new $sessionClass($this->specification->session); $this->vsm = new $vsmClass($this->specification->vsmanager); $this->services = new $serviceManagerClass($this->specification->services); $this->session->start(); $userClass = $this->handlers['user']; if (!empty($userClass)) { if ($this->session->has($this->id . ':' . self::SESSION_USER)) { $this->user = pradoUnserializeObject($this->session->get($this->id . ':' . self::SESSION_USER)); } if (!$this->user instanceof IUser) { $this->user = new $userClass($this->specification->user); } if (!$this->user instanceof IUser) { throw new Exception('User class must implement IUser interface.'); } } // load the theme if one was declared in the app.spec file if (is_file($this->getThemeFile())) { $this->theme = $this->getResourceParser()->parseTheme(file_get_contents($this->getThemeFile())); } //globalization should be last, it may require Request, Session, Resource and User if ($this->specification->globalization->length) { $this->globalization = new $globalizationClass($this->specification->globalization); } }