From 8dfd5f8d3050149be9ebcfcc1561b162d845460f Mon Sep 17 00:00:00 2001 From: David Windell Date: Mon, 17 Jul 2017 13:22:51 +0100 Subject: [PATCH] Fix Zf2 BC break --- composer.json | 3 ++- .../DocumentationControllerFactory.php | 27 ++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 41bdb0f..0e9a3dd 100644 --- a/composer.json +++ b/composer.json @@ -3,11 +3,12 @@ "description": "Zend Framework Module for Swagger resource file generation", "type": "library", "license": "Apache-2.0", - "homepage": "https://github.com/outeredge/SwaggerModule", + "homepage": "https://github.com/outeredge/SwaggerModule", "keywords": [ "api", "rest", "zf2", + "zf3", "swagger" ], "require": { diff --git a/src/SwaggerModule/Controller/DocumentationControllerFactory.php b/src/SwaggerModule/Controller/DocumentationControllerFactory.php index be3461a..2572fff 100644 --- a/src/SwaggerModule/Controller/DocumentationControllerFactory.php +++ b/src/SwaggerModule/Controller/DocumentationControllerFactory.php @@ -14,20 +14,28 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * @copyright Copyright (c) 2012 OuterEdge UK Ltd (http://www.outeredgeuk.com) + * @copyright Copyright (c) 2017 OuterEdge UK Ltd (https://outeredgeuk.com) * @license http://www.apache.org/licenses/LICENSE-2.0 */ namespace SwaggerModule\Controller; -use Zend\ServiceManager\Factory\FactoryInterface; use Interop\Container\ContainerInterface; +use Zend\ServiceManager\AbstractFactoryInterface; +use Zend\ServiceManager\ServiceLocatorInterface; -/** - * DocumentationController factory - */ -class DocumentationControllerFactory implements FactoryInterface +class DocumentationControllerFactory implements AbstractFactoryInterface { + public function canCreate(ContainerInterface $container, $requestedName) + { + return class_exists($requestedName); + } + + public function canCreateServiceWithName(ServiceLocatorInterface $services, $name, $requestedName) + { + return $this->canCreate($services, $requestedName); + } + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $controller = new DocumentationController(); @@ -36,4 +44,9 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o $controller->setSwagger($swagger); return $controller; } -} + + public function createServiceWithName(ServiceLocatorInterface $services, $name, $requestedName) + { + return $this($services, $requestedName); + } +} \ No newline at end of file