Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit 0aa670b

Browse files
committed
Lift non-interop container restriction
1 parent 1157028 commit 0aa670b

File tree

2 files changed

+1
-36
lines changed

2 files changed

+1
-36
lines changed

src/ZendViewRendererFactory.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99

1010
namespace Zend\Expressive\ZendView;
1111

12-
use Interop\Container\ContainerInterface as InteropContainerInterface;
1312
use Psr\Container\ContainerInterface;
1413
use Zend\Expressive\Helper\ServerUrlHelper as BaseServerUrlHelper;
1514
use Zend\Expressive\Helper\UrlHelper as BaseUrlHelper;
1615
use Zend\View\HelperPluginManager;
1716
use Zend\View\Renderer\PhpRenderer;
1817
use Zend\View\Resolver;
1918

20-
use function get_class;
2119
use function is_array;
2220
use function is_numeric;
2321
use function sprintf;
@@ -136,28 +134,12 @@ private function injectHelpers(PhpRenderer $renderer, ContainerInterface $contai
136134
$renderer->setHelperPluginManager($helpers);
137135
}
138136

139-
/**
140-
* @throws Exception\InvalidContainerException if the $container argument
141-
* does not implement InteropContainerInterface.
142-
*/
143137
private function retrieveHelperManager(ContainerInterface $container) : HelperPluginManager
144138
{
145139
if ($container->has(HelperPluginManager::class)) {
146140
return $container->get(HelperPluginManager::class);
147141
}
148142

149-
if (! $container instanceof InteropContainerInterface) {
150-
throw new Exception\InvalidContainerException(sprintf(
151-
'%s expects a %s instance to its constructor; however, your service'
152-
. ' container is an instance of %s, which does not implement that'
153-
. ' interface. Consider switching to zend-servicemanager for your'
154-
. ' container implementation if you wish to use the zend-view renderer.',
155-
HelperPluginManager::class,
156-
InteropContainerInterface::class,
157-
get_class($container)
158-
));
159-
}
160-
161143
return new HelperPluginManager($container);
162144
}
163145
}

test/ZendViewRendererFactoryTest.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99

1010
namespace ZendTest\Expressive\ZendView;
1111

12-
use Interop\Container\ContainerInterface;
12+
use Psr\Container\ContainerInterface;
1313
use PHPUnit\Framework\TestCase;
1414
use Prophecy\Prophecy\ObjectProphecy;
1515
use Prophecy\Prophecy\ProphecyInterface;
16-
use Psr\Container\ContainerInterface as PsrContainerInterface;
1716
use ReflectionProperty;
1817
use Zend\Expressive\Helper;
1918
use Zend\Expressive\Template\TemplatePath;
20-
use Zend\Expressive\ZendView\Exception\InvalidContainerException;
2119
use Zend\Expressive\ZendView\ServerUrlHelper;
2220
use Zend\Expressive\ZendView\UrlHelper;
2321
use Zend\Expressive\ZendView\ZendViewRenderer;
@@ -371,19 +369,4 @@ public function testWillUseRendererFromContainer()
371369
$composed = $this->fetchPhpRenderer($view);
372370
$this->assertSame($engine, $composed);
373371
}
374-
375-
public function testWillRaiseExceptionIfContainerDoesNotImplementInteropContainerInterface()
376-
{
377-
$container = $this->prophesize(PsrContainerInterface::class);
378-
$container->has('config')->willReturn(false);
379-
$container->get('config')->shouldNotBeCalled();
380-
$container->has(PhpRenderer::class)->willReturn(false);
381-
$container->get(PhpRenderer::class)->shouldNotBeCalled();
382-
$container->has(HelperPluginManager::class)->willReturn(false);
383-
384-
$factory = new ZendViewRendererFactory();
385-
386-
$this->expectException(InvalidContainerException::class);
387-
$factory($container->reveal());
388-
}
389372
}

0 commit comments

Comments
 (0)