Skip to content

Commit 3852849

Browse files
committed
Ensure all factories are compatible with both major versions of zend-servicemanager
- Removed `FactoryInterface` implmentation at class level; since each now implements an `__invoke()` method, they are each compatible with both major versions. - Updated all factories to only accept the arguments they use (as we are not implementing an interface). - Ensured all factories that pull the config service use `config` vs `Config` for forwards compatibility.
1 parent 40b967e commit 3852849

File tree

5 files changed

+32
-59
lines changed

5 files changed

+32
-59
lines changed

src/Factory/ApiProblemListenerFactory.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
<?php
2-
32
/**
43
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
5-
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
4+
* @copyright Copyright (c) 2014-2016 Zend Technologies USA Inc. (http://www.zend.com)
65
*/
76

87
namespace ZF\ApiProblem\Factory;
98

109
use Interop\Container\ContainerInterface;
11-
use Zend\ServiceManager\Factory\FactoryInterface;
1210
use ZF\ApiProblem\Listener\ApiProblemListener;
1311

14-
class ApiProblemListenerFactory implements FactoryInterface
12+
class ApiProblemListenerFactory
1513
{
1614
/**
17-
* @param \Interop\Container\ContainerInterface $container
18-
* @param string $requestedName
19-
* @param array|NULL $options
20-
*
21-
* @return \ZF\ApiProblem\Listener\ApiProblemListener
15+
* @param ContainerInterface $container
16+
* @return ApiProblemListener
2217
*/
23-
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
18+
public function __invoke(ContainerInterface $container)
2419
{
2520
$filters = null;
2621
$config = [];
2722

28-
if ($container->has('Config')) {
29-
$config = $container->get('Config');
23+
if ($container->has('config')) {
24+
$config = $container->get('config');
3025
}
3126

3227
if (isset($config['zf-api-problem']['accept_filters'])) {

src/Factory/ApiProblemRendererFactory.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
11
<?php
2-
32
/**
43
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
5-
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
4+
* @copyright Copyright (c) 2014-2016 Zend Technologies USA Inc. (http://www.zend.com)
65
*/
76

87
namespace ZF\ApiProblem\Factory;
98

109
use Interop\Container\ContainerInterface;
11-
use Zend\ServiceManager\Factory\FactoryInterface;
1210
use ZF\ApiProblem\View\ApiProblemRenderer;
1311

14-
/**
15-
* Class ApiProblemRendererFactory.
16-
*/
17-
class ApiProblemRendererFactory implements FactoryInterface
12+
class ApiProblemRendererFactory
1813
{
1914
/**
20-
* @param \Interop\Container\ContainerInterface $container
21-
* @param string $requestedName
22-
* @param array|NULL $options
23-
*
24-
* @return \ZF\ApiProblem\View\ApiProblemRenderer
15+
* @param ContainerInterface $container
16+
* @return ApiProblemRenderer
2517
*/
26-
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
18+
public function __invoke(ContainerInterface $container)
2719
{
28-
$config = $container->get('Config');
20+
$config = $container->get('config');
2921
$displayExceptions = isset($config['view_manager'])
3022
&& isset($config['view_manager']['display_exceptions'])
3123
&& $config['view_manager']['display_exceptions'];

src/Factory/ApiProblemStrategyFactory.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
11
<?php
2-
32
/**
43
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
5-
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
4+
* @copyright Copyright (c) 2014-2016 Zend Technologies USA Inc. (http://www.zend.com)
65
*/
76

87
namespace ZF\ApiProblem\Factory;
98

109
use Interop\Container\ContainerInterface;
11-
use Zend\ServiceManager\Factory\FactoryInterface;
1210
use ZF\ApiProblem\View\ApiProblemRenderer;
1311
use ZF\ApiProblem\View\ApiProblemStrategy;
1412

15-
/**
16-
* Class ApiProblemStrategyFactory.
17-
*/
18-
class ApiProblemStrategyFactory implements FactoryInterface
13+
class ApiProblemStrategyFactory
1914
{
2015
/**
21-
* @param \Interop\Container\ContainerInterface $container
22-
* @param string $requestedName
23-
* @param array|NULL $options
24-
*
25-
* @return \ZF\ApiProblem\View\ApiProblemStrategy
16+
* @param ContainerInterface $container
17+
* @return ApiProblemStrategy
2618
*/
27-
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
19+
public function __invoke(ContainerInterface $container)
2820
{
2921
return new ApiProblemStrategy($container->get(ApiProblemRenderer::class));
3022
}

src/Factory/RenderErrorListenerFactory.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
11
<?php
2-
32
/**
43
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
5-
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
4+
* @copyright Copyright (c) 2014-2016 Zend Technologies USA Inc. (http://www.zend.com)
65
*/
76

87
namespace ZF\ApiProblem\Factory;
98

109
use Interop\Container\ContainerInterface;
11-
use Zend\ServiceManager\Factory\FactoryInterface;
1210
use ZF\ApiProblem\Listener\RenderErrorListener;
1311

14-
/**
15-
* Class RenderErrorListenerFactory.
16-
*/
17-
class RenderErrorListenerFactory implements FactoryInterface
12+
class RenderErrorListenerFactory
1813
{
1914
/**
20-
* @param \Interop\Container\ContainerInterface $container
21-
* @param string $requestedName
22-
* @param array|NULL $options
23-
*
24-
* @return \ZF\ApiProblem\Listener\RenderErrorListener
15+
* @param ContainerInterface $container
16+
* @return RenderErrorListener
2517
*/
26-
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
18+
public function __invoke(ContainerInterface $container)
2719
{
28-
$config = $container->get('Config');
20+
$config = $container->get('config');
2921
$displayExceptions = false;
3022

3123
if (isset($config['view_manager'])

src/Factory/SendApiProblemResponseListenerFactory.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
<?php
2-
32
/**
43
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
5-
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
4+
* @copyright Copyright (c) 2014-2016 Zend Technologies USA Inc. (http://www.zend.com)
65
*/
76

87
namespace ZF\ApiProblem\Factory;
98

109
use Interop\Container\ContainerInterface;
1110
use Zend\Http\Response as HttpResponse;
12-
use Zend\ServiceManager\Factory\FactoryInterface;
1311
use ZF\ApiProblem\Listener\SendApiProblemResponseListener;
1412

15-
class SendApiProblemResponseListenerFactory implements FactoryInterface
13+
class SendApiProblemResponseListenerFactory
1614
{
17-
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
15+
/**
16+
* @param ContainerInterface $container
17+
* @return SendApiProblemResponseListener
18+
*/
19+
public function __invoke(ContainerInterface $container)
1820
{
19-
$config = $container->get('Config');
21+
$config = $container->get('config');
2022
$displayExceptions = isset($config['view_manager'])
2123
&& isset($config['view_manager']['display_exceptions'])
2224
&& $config['view_manager']['display_exceptions'];

0 commit comments

Comments
 (0)