Border ordering (#273)
* Fix #271 * Minor fix for quick copy+paste * Added link to issue #271
This commit is contained in:
1 parent
54a1a09e29
commit
7a613eed8c
4 files changed
+75
-5
No files matched your search
@@ -35,6 +35,24 @@ class Border
|
||||
$this->setParts($borderParts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name The name of the border part
|
||||
* @return null|BorderPart
|
||||
*/
|
||||
public function getPart($name)
|
||||
{
|
||||
return $this->hasPart($name) ? $this->parts[$name] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name The name of the border part
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPart($name)
|
||||
{
|
||||
return isset($this->parts[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -110,13 +110,22 @@ EOD;
|
||||
$border = $style->getBorder();
|
||||
if ($border) {
|
||||
$content .= '<border>';
|
||||
foreach ($border->getParts() as $part) {
|
||||
/** @var $part \Box\Spout\Writer\Style\BorderPart */
|
||||
$content .= BorderHelper::serializeBorderPart($part);
|
||||
|
||||
// @link https://github.com/box/spout/issues/271
|
||||
$sortOrder = ['left', 'right', 'top', 'bottom'];
|
||||
|
||||
foreach ($sortOrder as $partName) {
|
||||
if ($border->hasPart($partName)) {
|
||||
/** @var $part \Box\Spout\Writer\Style\BorderPart */
|
||||
$part = $border->getPart($partName);
|
||||
$content .= BorderHelper::serializeBorderPart($part);
|
||||
}
|
||||
}
|
||||
|
||||
$content .= '</border>';
|
||||
|
||||
} else {
|
||||
$content .= '<border><left/><right/><top/><bottom/><diagonal/></border>';
|
||||
$content .= '<border><left/><right/><top/><bottom/></border>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user