|
3 | 3 | namespace SlmQueueSqs\Factory; |
4 | 4 |
|
5 | 5 | use Aws\Sdk as Aws; |
| 6 | +use Interop\Container\ContainerInterface; |
6 | 7 | use SlmQueue\Job\JobPluginManager; |
7 | 8 | use SlmQueueSqs\Options\SqsQueueOptions; |
8 | 9 | use SlmQueueSqs\Queue\SqsQueue; |
|
15 | 16 | class SqsQueueFactory implements FactoryInterface |
16 | 17 | { |
17 | 18 | /** |
18 | | - * {@inheritDoc} |
| 19 | + * @param ContainerInterface $container |
| 20 | + * @param string $requestedName |
| 21 | + * @param array|null $options |
| 22 | + * @return SqsQueue |
19 | 23 | */ |
20 | | - public function createService(ServiceLocatorInterface $serviceLocator, $name = '', $requestedName = '') |
| 24 | + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
21 | 25 | { |
22 | | - $parentLocator = $serviceLocator->getServiceLocator(); |
23 | | - $sqsClient = $parentLocator->get(Aws::class)->createSqs(); |
24 | | - $jobPluginManager = $parentLocator->get(JobPluginManager::class); |
| 26 | + $sqsClient = $container->get(Aws::class)->createSqs(); |
| 27 | + $jobPluginManager = $container->get(JobPluginManager::class); |
25 | 28 |
|
26 | 29 | // Let's see if we have options for this specific queue |
27 | | - $config = $parentLocator->get('Config'); |
28 | | - $config = $config['slm_queue']['queues']; |
| 30 | + $config = $container->get('Config'); |
| 31 | + $config = $config['slm_queue']['queues']; |
29 | 32 |
|
30 | | - $options = new SqsQueueOptions(isset($config[$requestedName]) ? $config[$requestedName] : array()); |
| 33 | + $options = new SqsQueueOptions(isset($config[$requestedName]) ? $config[$requestedName] : []); |
31 | 34 |
|
32 | 35 |
|
33 | 36 | return new SqsQueue($sqsClient, $options, $requestedName, $jobPluginManager); |
34 | 37 | } |
| 38 | + |
| 39 | + /** |
| 40 | + * {@inheritDoc} |
| 41 | + */ |
| 42 | + public function createService(ServiceLocatorInterface $serviceLocator, $name = '', $requestedName = '') |
| 43 | + { |
| 44 | + $parentLocator = $serviceLocator->getServiceLocator(); |
| 45 | + |
| 46 | + return $this($parentLocator, SqsQueue::class); |
| 47 | + } |
35 | 48 | } |
0 commit comments