1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
<?php
/* --------------------------------------------------------------
CustomerGroupServiceFactory.inc.php 2017-09-08
Gambio GmbH
http://www.gambio.de
Copyright (c) 2017 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]
--------------------------------------------------------------
*/
/**
* Class CustomerGroupServiceFactory
* *
* @category System
* @package CustomerGroup
* @subpackage Factories
*/
class CustomerGroupServiceFactory
{
/**
* @var \CI_DB_query_builder
*/
protected $queryBuilder;
/**
* @var \CustomerGroupAccessRepository
*/
protected $accessRepository;
/**
* @var \CustomerGroupWriteServiceInterface
*/
protected $writeService;
/**
* @var \CustomerGroupReadServiceInterface
*/
protected $readerService;
/**
* CustomerGroupServiceFactory constructor.
*
* @param \CI_DB_query_builder $queryBuilder for database connection.
*/
public function __construct(CI_DB_query_builder $queryBuilder)
{
$this->queryBuilder = $queryBuilder;
}
/**
* Creates a customer group write service.
*
* @return \CustomerGroupWriteServiceInterface
*/
public function createWriteService()
{
$this->_createWriter();
return $this->writeService;
}
/**
* Creates a customer group read service.
*
* @return \CustomerGroupReadServiceInterface
*/
public function createReadService()
{
$this->_createRepository();
$this->_createReader();
return $this->readerService;
}
/**
* Creates a new instance of a CustomerGroupRepository object.
* Consecutive calls provide the same object.
*
* @return \CustomerGroupAccessRepository
*/
protected function _createRepository()
{
if(null === $this->accessRepository)
{
$languageProvider = MainFactory::create('LanguageProvider', $this->queryBuilder);
$writer = MainFactory::create('CustomerGroupWriter', $this->queryBuilder, $languageProvider);
$deleter = MainFactory::create('CustomerGroupDeleter', $this->queryBuilder);
$repository = MainFactory::create('CustomerGroupRepository', $writer, $deleter);
$reader = MainFactory::create('CustomerGroupReader', $this->queryBuilder);
$factory = MainFactory::create('CustomerGroupFactory', $repository);
$this->accessRepository = MainFactory::create('CustomerGroupAccessRepository', $factory, $reader,
$languageProvider);
}
return $this->accessRepository;
}
/**
* Creates a new instance of a CustomerGroupReadService object.
* Consecutive calls provide the same object.
*
* @return \CustomerGroupReadServiceInterface
*/
protected function _createReader()
{
if(null === $this->readerService)
{
$this->readerService = MainFactory::create('CustomerGroupReadService', $this->accessRepository);
}
return $this->readerService;
}
/**
* Creates a new instance of a CustomerGroupWritService object.
* Consecutive calls provide the same object.
*
* @return \CustomerGroupWriteServiceInterface
*/
protected function _createWriter()
{
if(null === $this->writeService)
{
$this->writeService = MainFactory::create('CustomerGroupWriteService');
}
return $this->writeService;
}
}