本文整理汇总了PHP中MetadataDescription::getStatements方法的典型用法代码示例。如果您正苦于以下问题:PHP MetadataDescription::getStatements方法的具体用法?PHP MetadataDescription::getStatements怎么用?PHP MetadataDescription::getStatements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetadataDescription
的用法示例。
在下文中一共展示了MetadataDescription::getStatements方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serializeCitationDescription
private function serializeCitationDescription(MetadataDescription &$citationDescription)
{
// Prepare transformation tables for the output serialization:
// - the following lines will be deleted from our output file
static $linesToDelete = array(' [0-9]+ => ', ' array \\(', ' \'_data\' => ', ' \\),');
// Transform person descriptions to arrays
$citationDescriptionArray = $citationDescription->getStatements();
$personDescriptionProperties = array('person-group[@person-group-type="author"]', 'person-group[@person-group-type="editor"]');
foreach ($personDescriptionProperties as $personDescriptionProperty) {
if (isset($citationDescriptionArray[$personDescriptionProperty])) {
foreach ($citationDescriptionArray[$personDescriptionProperty] as &$person) {
$person = $person->getStatements();
}
}
}
// Transform the result into an array that we can serialize
// in a human-readable form and also re-import as PHP-parsable code.
$citationDescriptionOutput = var_export($citationDescriptionArray, true);
$citationDescriptionOutputArray = explode("\n", $citationDescriptionOutput);
foreach ($citationDescriptionOutputArray as $key => &$citationDescriptionOutputLine) {
// Remove redundant lines
foreach ($linesToDelete as $lineToDelete) {
if (preg_match('/^' . $lineToDelete . '$/', $citationDescriptionOutputLine)) {
unset($citationDescriptionOutputArray[$key]);
}
}
// Correctly indent the output line
$citationDescriptionOutputLine = "\t\t\t" . preg_replace('/^\\t\\t\\t/', "\t\t", str_replace(' ', "\t", $citationDescriptionOutputLine));
}
// Create the final serialized format
return implode("\n", $citationDescriptionOutputArray);
}