/** * @throws SMSConfigurationException * @version : v0.1 */ public function setup() { $fileNamespace = $this->getXMLFileNamespace(); $vendor = RootClassLoader::getVendor($fileNamespace); $libPath = RootClassLoader::getLoaderByVendor($vendor)->getRootPath(); $basePath = str_replace('\\', '/', RootClassLoader::getNamespaceWithoutVendor($fileNamespace)); $filename = $this->getXMLFilename(); $fullPath = $libPath . (empty($basePath) ? '' : '/' . $basePath) . '/' . $filename; if (!file_exists($fullPath)) { throw new SMSConfigurationException('[SMSXMLMapper::setup()] XML file "' . $filename . '" in namespace "' . $fileNamespace . '" could not be found. (Full path: "' . $fullPath . '").', E_USER_ERROR); } $this->XML_DOMDocument = new \DOMDocument(); $this->XML_DOMDocument->load($fullPath); // we need to validate the document, to let the DTD be parsed and the id attribute be recognized as id by DOMDocument::getElementById(). // do not care about failures this time $this->XML_DOMDocument->validate(); }
public function testGetNamespaceWithoutVendor() { $this->assertEquals('core\\loader', RootClassLoader::getNamespaceWithoutVendor('APF\\core\\loader\\StandardClassLoader')); $this->assertEquals('core', RootClassLoader::getNamespaceWithoutVendor('APF\\core\\StandardClassLoader')); }