Inject GlobalFunctionsHelper through constructor for Writers
This commit is contained in:
parent
7ec0f565fd
commit
7dceff1560
@ -6,7 +6,7 @@ use Box\Spout\Writer\Common\Manager\OptionsManagerInterface;
|
|||||||
use Box\Spout\Writer\Common\Manager\WorkbookManagerInterface;
|
use Box\Spout\Writer\Common\Manager\WorkbookManagerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface GeneralFactoryInterface
|
* Interface InternalFactoryInterface
|
||||||
*
|
*
|
||||||
* @package Box\Spout\Writer\Common\Creator
|
* @package Box\Spout\Writer\Common\Creator
|
||||||
*/
|
*/
|
||||||
|
@ -49,11 +49,17 @@ abstract class WriterAbstract implements WriterInterface
|
|||||||
/**
|
/**
|
||||||
* @param OptionsManagerInterface $optionsManager
|
* @param OptionsManagerInterface $optionsManager
|
||||||
* @param StyleMerger $styleMerger
|
* @param StyleMerger $styleMerger
|
||||||
|
* @param GlobalFunctionsHelper $globalFunctionsHelper
|
||||||
*/
|
*/
|
||||||
public function __construct(OptionsManagerInterface $optionsManager, StyleMerger $styleMerger)
|
public function __construct(
|
||||||
|
OptionsManagerInterface $optionsManager,
|
||||||
|
StyleMerger $styleMerger,
|
||||||
|
GlobalFunctionsHelper $globalFunctionsHelper)
|
||||||
{
|
{
|
||||||
$this->optionsManager = $optionsManager;
|
$this->optionsManager = $optionsManager;
|
||||||
$this->styleMerger = $styleMerger;
|
$this->styleMerger = $styleMerger;
|
||||||
|
$this->globalFunctionsHelper = $globalFunctionsHelper;
|
||||||
|
|
||||||
$this->resetRowStyleToDefault();
|
$this->resetRowStyleToDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,16 +103,6 @@ abstract class WriterAbstract implements WriterInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \Box\Spout\Common\Helper\GlobalFunctionsHelper $globalFunctionsHelper
|
|
||||||
* @return WriterAbstract
|
|
||||||
*/
|
|
||||||
public function setGlobalFunctionsHelper($globalFunctionsHelper)
|
|
||||||
{
|
|
||||||
$this->globalFunctionsHelper = $globalFunctionsHelper;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inits the writer and opens it to accept data.
|
* Inits the writer and opens it to accept data.
|
||||||
* By using this method, the data will be written to a file.
|
* By using this method, the data will be written to a file.
|
||||||
|
@ -28,25 +28,13 @@ class WriterFactory
|
|||||||
*/
|
*/
|
||||||
public static function create($writerType)
|
public static function create($writerType)
|
||||||
{
|
{
|
||||||
$writer = null;
|
|
||||||
|
|
||||||
switch ($writerType) {
|
switch ($writerType) {
|
||||||
case Type::CSV:
|
case Type::CSV: return self::getCSVWriter();
|
||||||
$writer = self::getCSVWriter();
|
case Type::XLSX: return self::getXLSXWriter();
|
||||||
break;
|
case Type::ODS: return self::getODSWriter();
|
||||||
case Type::XLSX:
|
|
||||||
$writer = self::getXLSXWriter();
|
|
||||||
break;
|
|
||||||
case Type::ODS:
|
|
||||||
$writer = self::getODSWriter();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedTypeException('No writers supporting the given type: ' . $writerType);
|
throw new UnsupportedTypeException('No writers supporting the given type: ' . $writerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
$writer->setGlobalFunctionsHelper(new GlobalFunctionsHelper());
|
|
||||||
|
|
||||||
return $writer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,8 +44,9 @@ class WriterFactory
|
|||||||
{
|
{
|
||||||
$optionsManager = new CSV\Manager\OptionsManager();
|
$optionsManager = new CSV\Manager\OptionsManager();
|
||||||
$styleMerger = new StyleMerger();
|
$styleMerger = new StyleMerger();
|
||||||
|
$globalFunctionsHelper = new GlobalFunctionsHelper();
|
||||||
|
|
||||||
return new CSV\Writer($optionsManager, $styleMerger);
|
return new CSV\Writer($optionsManager, $styleMerger, $globalFunctionsHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,9 +57,10 @@ class WriterFactory
|
|||||||
$styleBuilder = new StyleBuilder();
|
$styleBuilder = new StyleBuilder();
|
||||||
$optionsManager = new XLSX\Manager\OptionsManager($styleBuilder);
|
$optionsManager = new XLSX\Manager\OptionsManager($styleBuilder);
|
||||||
$styleMerger = new StyleMerger();
|
$styleMerger = new StyleMerger();
|
||||||
$generalFactory = new XLSX\Creator\InternalFactory(new EntityFactory());
|
$globalFunctionsHelper = new GlobalFunctionsHelper();
|
||||||
|
$internalFactory = new XLSX\Creator\InternalFactory(new EntityFactory());
|
||||||
|
|
||||||
return new XLSX\Writer($optionsManager, $styleMerger, $generalFactory);
|
return new XLSX\Writer($optionsManager, $styleMerger, $globalFunctionsHelper, $internalFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,8 +71,9 @@ class WriterFactory
|
|||||||
$styleBuilder = new StyleBuilder();
|
$styleBuilder = new StyleBuilder();
|
||||||
$optionsManager = new ODS\Manager\OptionsManager($styleBuilder);
|
$optionsManager = new ODS\Manager\OptionsManager($styleBuilder);
|
||||||
$styleMerger = new StyleMerger();
|
$styleMerger = new StyleMerger();
|
||||||
$generalFactory = new ODS\Creator\InternalFactory(new EntityFactory());
|
$globalFunctionsHelper = new GlobalFunctionsHelper();
|
||||||
|
$internalFactory = new ODS\Creator\InternalFactory(new EntityFactory());
|
||||||
|
|
||||||
return new ODS\Writer($optionsManager, $styleMerger, $generalFactory);
|
return new ODS\Writer($optionsManager, $styleMerger, $globalFunctionsHelper, $internalFactory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Box\Spout\Writer;
|
namespace Box\Spout\Writer;
|
||||||
|
|
||||||
|
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
||||||
use Box\Spout\Writer\Common\Manager\OptionsManagerInterface;
|
use Box\Spout\Writer\Common\Manager\OptionsManagerInterface;
|
||||||
use Box\Spout\Writer\Common\Entity\Options;
|
use Box\Spout\Writer\Common\Entity\Options;
|
||||||
use Box\Spout\Writer\Common\Entity\Worksheet;
|
use Box\Spout\Writer\Common\Entity\Worksheet;
|
||||||
@ -28,11 +29,16 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
|
|||||||
/**
|
/**
|
||||||
* @param OptionsManagerInterface $optionsManager
|
* @param OptionsManagerInterface $optionsManager
|
||||||
* @param StyleMerger $styleMerger
|
* @param StyleMerger $styleMerger
|
||||||
|
* @param GlobalFunctionsHelper $globalFunctionsHelper
|
||||||
* @param InternalFactoryInterface $internalFactory
|
* @param InternalFactoryInterface $internalFactory
|
||||||
*/
|
*/
|
||||||
public function __construct(OptionsManagerInterface $optionsManager, StyleMerger $styleMerger, InternalFactoryInterface $internalFactory)
|
public function __construct(
|
||||||
|
OptionsManagerInterface $optionsManager,
|
||||||
|
StyleMerger $styleMerger,
|
||||||
|
GlobalFunctionsHelper $globalFunctionsHelper,
|
||||||
|
InternalFactoryInterface $internalFactory)
|
||||||
{
|
{
|
||||||
parent::__construct($optionsManager, $styleMerger);
|
parent::__construct($optionsManager, $styleMerger, $globalFunctionsHelper);
|
||||||
$this->internalFactory = $internalFactory;
|
$this->internalFactory = $internalFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user