public function load(Config $config) { $this->resourceMap = CacheManager::loadResource(self::CONTEXT_RESOURCE_NAME, CacheManager::APPLICATION_SCOPE); if ($this->resourceMap == null) { ApplicationInitializer::loadAssets(ASSETS_DIRECTORY); $this->resourceMap = $this->loadResourceMap($this->getClasses()); CacheManager::saveResource(self::CONTEXT_RESOURCE_NAME, $this->resourceMap, CacheManager::APPLICATION_SCOPE); } $this->createResources(); $this->loadDataSources($config->getDataSources()); return new ApplicationContext($this->resources); }
private function scanPages() { ApplicationInitializer::loadAssets(ASSETS_DIRECTORY); $this->pages = array(); $scanner = new ClassScanner(array(new SubClassRule('\\picon\\WebPage'))); $pages = $scanner->scanForName(); foreach ($pages as $pageName) { $this->addToPath($pageName, $pageName); } $pathScanner = new ClassScanner(array(new AnnotationRule('Path'))); foreach ($pathScanner->scanForReflection($pages) as $reflection) { $pathAnnoation = $reflection->getAnnotation('Path'); $path = $pathAnnoation->path; if (empty($path)) { throw new \UnexpectedValueException(sprintf("Expecting path annoation to have a path value for class %s", $reflection->getName())); } $this->addToPath($path, $reflection->getNamespaceName() . '\\' . $reflection->getName()); } PiconApplication::get()->getPageMapInitializationListener()->onInitialize($this); }