Refactor writers for better DI (#427)
This commit is a big refactor that improves the code organization. It focuses on how dependencies are injected into the different classes. This is now done via some factories. Also, the code is now built around entities (data model that only exposes getters and setters), managers (used to manage an entity) and helpers (used by the managers to perform some specific tasks). The refactoring is not fully complete, as some dependencies are still hidden...
This commit is contained in:
1 parent
a366d0d0af
commit
bc17311f5f
37 files changed
+1529
-1031
No files matched your search
@@ -5,6 +5,7 @@ namespace Box\Spout\Writer;
|
||||
use Box\Spout\Common\Exception\UnsupportedTypeException;
|
||||
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\Writer\Factory\EntityFactory;
|
||||
use Box\Spout\Writer\Style\StyleBuilder;
|
||||
|
||||
/**
|
||||
@@ -64,8 +65,9 @@ class WriterFactory
|
||||
{
|
||||
$styleBuilder = new StyleBuilder();
|
||||
$optionsManager = new XLSX\Manager\OptionsManager($styleBuilder);
|
||||
$generalFactory = new XLSX\Factory\InternalFactory(new EntityFactory());
|
||||
|
||||
return new XLSX\Writer($optionsManager);
|
||||
return new XLSX\Writer($optionsManager, $generalFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +77,8 @@ class WriterFactory
|
||||
{
|
||||
$styleBuilder = new StyleBuilder();
|
||||
$optionsManager = new ODS\Manager\OptionsManager($styleBuilder);
|
||||
$generalFactory = new ODS\Factory\InternalFactory(new EntityFactory());
|
||||
|
||||
return new ODS\Writer($optionsManager);
|
||||
return new ODS\Writer($optionsManager, $generalFactory);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user