本文整理汇总了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());
}