/** * 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 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); }
/** * Gets a request object from the provided request XML * @param string $xml The XML of a XML-RPC request * @return Request */ public static function fromXMLString($xml) { $xml = trim($xml); if (empty($xml)) { throw new XmlRpcException('Empty request recieved', 1); } $dom = new Document('1.0', 'utf-8'); $dom->preserveWhiteSpace = false; $dom->setRelaxNGFileFromConfig(self::CONFIG_REQUEST_RNG); try { $dom->loadXML($xml); } catch (Exception $exception) { throw new XmlRpcException($xml, 0, $exception); } $element = $dom->documentElement; return new self($element); }
/** * 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; }