本文整理匯總了PHP中PhpOffice\PhpWord\Shared\XMLWriter::writeAttributeIf方法的典型用法代碼示例。如果您正苦於以下問題:PHP XMLWriter::writeAttributeIf方法的具體用法?PHP XMLWriter::writeAttributeIf怎麽用?PHP XMLWriter::writeAttributeIf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PhpOffice\PhpWord\Shared\XMLWriter
的用法示例。
在下文中一共展示了XMLWriter::writeAttributeIf方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: writeFont
/**
* Write level font.
*
* @since 0.11.0
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\NumberingLevel $level
* @return void
* @todo Use font style writer
*/
private function writeFont(XMLWriter $xmlWriter, NumberingLevel $level)
{
$font = $level->getFont();
$hint = $level->getHint();
$xmlWriter->startElement('w:rPr');
$xmlWriter->startElement('w:rFonts');
$xmlWriter->writeAttributeIf($font !== null, 'w:ascii', $font);
$xmlWriter->writeAttributeIf($font !== null, 'w:hAnsi', $font);
$xmlWriter->writeAttributeIf($font !== null, 'w:cs', $font);
$xmlWriter->writeAttributeIf($hint !== null, 'w:hint', $hint);
$xmlWriter->endElement();
// w:rFonts
$xmlWriter->endElement();
// w:rPr
}
示例2: writePolyline
/**
* Write polyline.
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Shape $style
* @return void
*/
private function writePolyline(XMLWriter $xmlWriter, ShapeStyle $style)
{
$xmlWriter->writeAttributeIf($style->getPoints() !== null, 'points', $style->getPoints());
}