Refactory Writer Styles to match new code organization (#433)
Decomposed old StyleHelper into StyleManager, StyleRegistry and StyleMerger.
This commit is contained in:
1 parent
238756ab6e
commit
cc9a0b526b
34 files changed
+1005
-762
No files matched your search
@@ -10,7 +10,7 @@ use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
||||
use Box\Spout\Writer\Common\Entity\Options;
|
||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
use Box\Spout\Writer\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Writer\Common\Manager\StyleManager;
|
||||
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
|
||||
use Box\Spout\Writer\Exception\WriterAlreadyOpenedException;
|
||||
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||
|
||||
@@ -37,8 +37,8 @@ abstract class WriterAbstract implements WriterInterface
|
||||
/** @var OptionsManagerInterface Writer options manager */
|
||||
protected $optionsManager;
|
||||
|
||||
/** @var StyleManager Style manager */
|
||||
protected $styleManager;
|
||||
/** @var StyleMerger Helps merge styles together */
|
||||
protected $styleMerger;
|
||||
|
||||
/** @var Style Style to be applied to the next written row(s) */
|
||||
protected $rowStyle;
|
||||
@@ -46,6 +46,17 @@ abstract class WriterAbstract implements WriterInterface
|
||||
/** @var string Content-Type value for the header - to be defined by child class */
|
||||
protected static $headerContentType;
|
||||
|
||||
/**
|
||||
* @param OptionsManagerInterface $optionsManager
|
||||
* @param StyleMerger $styleMerger
|
||||
*/
|
||||
public function __construct(OptionsManagerInterface $optionsManager, StyleMerger $styleMerger)
|
||||
{
|
||||
$this->optionsManager = $optionsManager;
|
||||
$this->styleMerger = $styleMerger;
|
||||
$this->resetRowStyleToDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the streamer and makes it ready to accept data.
|
||||
*
|
||||
@@ -71,17 +82,6 @@ abstract class WriterAbstract implements WriterInterface
|
||||
*/
|
||||
abstract protected function closeWriter();
|
||||
|
||||
/**
|
||||
* @param OptionsManagerInterface $optionsManager
|
||||
* @param StyleManager $styleManager
|
||||
*/
|
||||
public function __construct(OptionsManagerInterface $optionsManager, StyleManager $styleManager)
|
||||
{
|
||||
$this->optionsManager = $optionsManager;
|
||||
$this->styleManager = $styleManager;
|
||||
$this->resetRowStyleToDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default styles for all rows added with "addRow".
|
||||
* Overriding the default style instead of using "addRowWithStyle" improves performance by 20%.
|
||||
@@ -327,7 +327,7 @@ abstract class WriterAbstract implements WriterInterface
|
||||
{
|
||||
// Merge given style with the default one to inherit custom properties
|
||||
$defaultRowStyle = $this->optionsManager->getOption(Options::DEFAULT_ROW_STYLE);
|
||||
$this->rowStyle = $this->styleManager->merge($style, $defaultRowStyle);
|
||||
$this->rowStyle = $this->styleMerger->merge($style, $defaultRowStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user