/** * Reads the routes from the provided file * @param zibo\library\filesystem\File $file * @return array Array with Route objects as value and their path as key */ private function readRoutesFromFile(File $file) { $dom = new Document(); $dom->setRelaxNGFileFromConfig(self::CONFIG_ROUTES_RNG); $dom->load($file); return $this->getRoutesFromElement($file, $dom->documentElement); }
/** * Read the modules from the provided path * @param zibo\library\filesystem\File $path Path to read the module definitions from * @return array Array with Module instances * @throws zibo\admin\model\exception\ModuleDefinitionNotFoundException when no module definition could be read from the provided path */ public function readModules(File $path) { $xmlFile = new File($path, self::MODULE_FILE); if (!$xmlFile->exists()) { throw new ModuleDefinitionNotFoundException($path); } $dom = new Document('1.0', 'utf-8'); $dom->preserveWhiteSpace = false; $dom->setSchemaFileFromConfig(self::CONFIG_MODULES_SCHEMA); $dom->load($xmlFile->getPath()); return $this->readModulesFromElement($dom->documentElement, self::TAG_MODULE); }
public function testLoadWithValidXMLFile() { $doc = new Document('1.0', 'utf-8'); $doc->load('application/data/xml/test.valid.xml'); }
/** * Read models from a xml model definition file * @param zibo\library\filesystem\File $file * @return array Array with Model instances */ public function readModelsFromFile(File $file) { $dom = new Document('1.0', 'utf-8'); $dom->preserveWhiteSpace = false; $dom->setRelaxNGFileFromConfig(self::CONFIG_SCHEMA_MODELS); @$dom->load($file); $rootElement = $dom->documentElement; return $this->getModelsFromElement($rootElement, $file); }
/** * Reads the routes from the provided file * @param zibo\library\filesystem\File $file * @return array Array with Route objects as value and their path as key */ private function readRoutesFromFile(File $file) { $dom = new Document(); $relaxNg = $this->zibo->getConfigValue(self::CONFIG_RNG); if ($relaxNg) { $dom->setRelaxNGFile($relaxNg); } $dom->load($file); return $this->getRoutesFromElement($file, $dom->documentElement); }
/** * Reads the index of this repository * @return null */ private function readIndexFile() { $indexFile = new File($this->directory, self::INDEX_FILE); $dom = new Document('1.0', 'utf-8'); $dom->formatOutput = true; $dom->preserveWhiteSpace = false; if (!$indexFile->exists()) { Zibo::getInstance()->runEvent(Zibo::EVENT_LOG, 'Initializing new index file', $indexFile, 0, RepositoryModule::LOG_NAME); $modulesElement = $dom->createElement(RepositoryModule::TAG_MODULES); $repositoryElement = $dom->createElement(RepositoryModule::TAG_REPOSITORY); $repositoryElement->appendChild($modulesElement); $dom->appendChild($repositoryElement); } else { $dom->setRelaxNGFileFromConfig(self::CONFIG_REPOSITORY_RNG); $success = @$dom->load($indexFile); if (!$success) { $error = error_get_last(); throw new ZiboException("Failed loading {$indexFile} into a DOM tree: " . $error['message']); } } $this->indexDom = $dom; }
/** * Reads the dependencies from the provided file and adds them to the * provided container * @param zibo\core\di\DependencyContainer $container * @param zibo\library\filesystem\File $file * @return null */ private function readDependencies(DependencyContainer $container, File $file) { $dom = new Document(); $dom->load($file); $dependencyElements = $dom->getElementsByTagName(self::TAG_DEPENDENCY); foreach ($dependencyElements as $dependencyElement) { $interface = $dependencyElement->getAttribute(self::ATTRIBUTE_INTERFACE); $className = $dependencyElement->getAttribute(self::ATTRIBUTE_CLASS); $id = $dependencyElement->getAttribute(self::ATTRIBUTE_ID); if (!$id) { $id = null; } $dependency = new Dependency($className, $id); $this->readCalls($dependency, $dependencyElement); $container->addDependency($interface, $dependency); } }