55use Aws \Sdk as AwsSdk ;
66use Aws \DynamoDb \SessionHandler ;
77use AwsModule \Session \SaveHandler \DynamoDb as DynamoDbSaveHandler ;
8+ use Interop \Container \ContainerInterface ;
89use Zend \ServiceManager \Exception \ServiceNotCreatedException ;
910use Zend \ServiceManager \FactoryInterface ;
1011use Zend \ServiceManager \ServiceLocatorInterface ;
1516class DynamoDbSessionSaveHandlerFactory implements FactoryInterface
1617{
1718 /**
18- * {@inheritDoc}
19+ * @param ContainerInterface $container
20+ * @param string $requestedName
21+ * @param array|null $options
1922 * @return DynamoDbSaveHandler
20- * @throws ServiceNotCreatedException if "dynamodb" configuration is not set up correctly
2123 */
22- public function createService ( ServiceLocatorInterface $ serviceLocator )
24+ public function __invoke ( ContainerInterface $ container , $ requestedName , array $ options = null )
2325 {
24- $ config = $ serviceLocator ->get ('Config ' );
26+ $ config = $ container ->get ('Config ' );
2527
2628 if (!isset ($ config ['aws_zf2 ' ]['session ' ]['save_handler ' ]['dynamodb ' ])) {
2729 throw new ServiceNotCreatedException (
@@ -32,11 +34,21 @@ public function createService(ServiceLocatorInterface $serviceLocator)
3234 }
3335
3436 /** @var AwsSdk $awsSdk */
35- $ awsSdk = $ serviceLocator ->get (AwsSdk::class);
37+ $ awsSdk = $ container ->get (AwsSdk::class);
3638
3739 $ saveHandlerConfig = $ config ['aws_zf2 ' ]['session ' ]['save_handler ' ]['dynamodb ' ];
3840 $ sessionHandler = SessionHandler::fromClient ($ awsSdk ->createDynamoDb (), $ saveHandlerConfig );
3941
4042 return new DynamoDbSaveHandler ($ sessionHandler );
4143 }
44+
45+ /**
46+ * {@inheritDoc}
47+ * @return DynamoDbSaveHandler
48+ * @throws ServiceNotCreatedException if "dynamodb" configuration is not set up correctly
49+ */
50+ public function createService (ServiceLocatorInterface $ serviceLocator )
51+ {
52+ return $ this ($ serviceLocator , DynamoDbSaveHandler::class);
53+ }
4254}
0 commit comments