Apply default row style in WorkbookManager

Instead of doing it in the Writer
This commit is contained in:
Adrien Loison committed 2017-11-05 14:13:22 +01:00
1 parent 3d0f108b1d
commit 8aec9ea992
6 files changed
+50 -37

No files matched your search

-23
View File
@@ -11,7 +11,6 @@ use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Writer\Common\Entity\Options;
use Box\Spout\Writer\Common\Entity\Row;
use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
use Box\Spout\Writer\Exception\WriterAlreadyOpenedException;
use Box\Spout\Writer\Exception\WriterNotOpenedException;
@@ -40,26 +39,20 @@ abstract class WriterAbstract implements WriterInterface
/** @var OptionsManagerInterface Writer options manager */
protected $optionsManager;
/** @var StyleMerger Helps merge styles together */
protected $styleMerger;
/** @var string Content-Type value for the header - to be defined by child class */
protected static $headerContentType;
/**
* @param OptionsManagerInterface $optionsManager
* @param StyleMerger $styleMerger
* @param GlobalFunctionsHelper $globalFunctionsHelper
* @param HelperFactory $helperFactory
*/
public function __construct(
OptionsManagerInterface $optionsManager,
StyleMerger $styleMerger,
GlobalFunctionsHelper $globalFunctionsHelper,
HelperFactory $helperFactory
) {
$this->optionsManager = $optionsManager;
$this->styleMerger = $styleMerger;
$this->globalFunctionsHelper = $globalFunctionsHelper;
$this->helperFactory = $helperFactory;
}
@@ -188,7 +181,6 @@ abstract class WriterAbstract implements WriterInterface
// empty $dataRow should not add an empty line
if ($row->hasCells()) {
try {
$this->applyDefaultRowStyle($row);
$this->addRowToWriter($row);
} catch (SpoutException $e) {
// if an exception occurs while writing data,
@@ -223,21 +215,6 @@ abstract class WriterAbstract implements WriterInterface
return $this;
}
/**
* @TODO: Move this into styleMerger
*
* @param Row $row
*/
private function applyDefaultRowStyle(Row $row)
{
$defaultRowStyle = $this->optionsManager->getOption(Options::DEFAULT_ROW_STYLE);
if ($defaultRowStyle !== null) {
$mergedStyle = $this->styleMerger->merge($row->getStyle(), $defaultRowStyle);
$row->setStyle($mergedStyle);
}
}
/**
* {@inheritdoc}
*/