| @@ 28-53 (lines=26) @@ | ||
| 25 | * @license X11 {@link http://opensource.org/licenses/mit-license.php} |
|
| 26 | * @see ClientPooler |
|
| 27 | */ |
|
| 28 | class ContainerModelLayerPooler extends ModelLayerPooler implements ContainerAwareInterface, ServiceMapInterface |
|
| 29 | { |
|
| 30 | use ContainerAwareTrait; |
|
| 31 | ||
| 32 | private $serviceMap = []; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * {@inheritdoc} |
|
| 36 | */ |
|
| 37 | public function addModelToServiceMapping($class, $serviceId) |
|
| 38 | { |
|
| 39 | $this->serviceMap[$class] = $serviceId; |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * {@inheritdoc} |
|
| 44 | */ |
|
| 45 | protected function createClient($class) |
|
| 46 | { |
|
| 47 | if (array_key_exists($class, $this->serviceMap)) { |
|
| 48 | return $this->container->get($this->serviceMap[$class]); |
|
| 49 | } |
|
| 50 | ||
| 51 | return parent::createClient($class); |
|
| 52 | } |
|
| 53 | } |
|
| 54 | ||
| @@ 27-52 (lines=26) @@ | ||
| 24 | * @license X11 {@link http://opensource.org/licenses/mit-license.php} |
|
| 25 | * @see Extension |
|
| 26 | */ |
|
| 27 | class ContainerModelPooler extends ModelPooler implements ContainerAwareInterface, ServiceMapInterface |
|
| 28 | { |
|
| 29 | use ContainerAwareTrait; |
|
| 30 | ||
| 31 | private $serviceMap = []; |
|
| 32 | ||
| 33 | /** |
|
| 34 | * {@inheritdoc} |
|
| 35 | */ |
|
| 36 | public function addModelToServiceMapping($class, $serviceId) |
|
| 37 | { |
|
| 38 | $this->serviceMap[$class] = $serviceId; |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * {@inheritdoc} |
|
| 43 | */ |
|
| 44 | protected function createClient($class) |
|
| 45 | { |
|
| 46 | if (array_key_exists($class, $this->serviceMap)) { |
|
| 47 | return $this->container->get($this->serviceMap[$class]); |
|
| 48 | } |
|
| 49 | ||
| 50 | return parent::createClient($class); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||