本文整理匯總了PHP中Configure::namespaceSource方法的典型用法代碼示例。如果您正苦於以下問題:PHP Configure::namespaceSource方法的具體用法?PHP Configure::namespaceSource怎麽用?PHP Configure::namespaceSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Configure
的用法示例。
在下文中一共展示了Configure::namespaceSource方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parse
/**
* Parses XML as a string and convert the defined custom tags into HTML.
*
* @param string $xml
* The XML string to be parsed. It represents a full document.
*
* @param string|null $emptyNamespaceSource
* Where do we look for custom tag definition files.
*
* @return string
* A string. It's supposed to be HTML.
*
* @throws \Error
* If XML is not well formed.
*
* @since 2.0.0 Second parameter becomes optional.
* @since 0.0.0
*
* @see https://github.com/Odepax/pasap/wiki/Namespaces#the-empty-namespace
* @see http://www.w3schools.com/xml/xml_validator.asp
*/
public static function parse(string $xml, $emptyNamespaceSource = null) : string
{
if ($emptyNamespaceSource !== null) {
Configure::namespaceSource('', $emptyNamespaceSource);
}
$document = new \DOMDocument("1.0", "UTF-8");
// Get rid of errors about HTML5.
libxml_use_internal_errors(true);
if (!$document->loadXML($xml)) {
throw new \Error("Why you no check your XML before parsing !?");
}
libxml_use_internal_errors(false);
if (Configure::get('doctype') === Configure::ALWAYS_HTML5) {
$output = '<!DOCTYPE html>';
} else {
if (!is_null($document->doctype)) {
if ($document->doctype->publicId === '' || $document->doctype->systemId === '') {
$output = "<!DOCTYPE {$document->doctype->name}>";
} else {
$output = "<!DOCTYPE {$document->doctype->name} PUBLIC \"{$document->doctype->publicId}\" \"{$document->doctype->systemId}\">";
}
} else {
$output = '';
}
}
$output .= new Element($document->documentElement);
switch (Configure::get('output')) {
case Configure::MINIFY:
return static::minify($output);
case Configure::PRETTIFY:
return static::prettify($output);
default:
return $output;
}
}