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

Create factories for selected view collaborators #4251

Merged

Conversation

weierophinney
Copy link
Member

Currently, I've made independent factories for HTTP and Console ViewManagers:

  • Created HttpViewManagerFactory and ConsoleViewManagerFactory; each
    will return the requested view manager.
  • ViewManagerFactory now consumes the above two factories (instead of
    using direct instantiation).

This will allow console endpoints to utilize the HTTP view manager if
desired by doing the following:

'service_manager' => array(
    'factories' => array(
        'ViewManager' => 'Zend\Mvc\Service\HttpViewManager',
    ),
),

@weierophinney
Copy link
Member Author

Failure is due to inability of Composer to lookup ocramius/proxy-manager. Marco's looking into that. Regardless, a work in progress...

- Created `HttpViewManagerFactory` and `ConsoleViewManagerFactory`; each
  will return the requested view manager.
- `ViewManagerFactory` now consumes the above two factories (instead of
  using direct instantiation).

This will allow console endpoints to utilize the HTTP view manager if
desired by doing the following:

```php
'service_manager' => array(
    'factories' => array(
        'ViewManager' => 'Zend\Mvc\Service\HttpViewManager',
    ),
),
```

I plan further refactoring to move the event listener registration into
individual factories as well.
@mwillbanks
Copy link
Contributor

@weierophinney looks like this breaks current tests:

There were 3 errors:

  1. ZendTest\View\Helper\UrlIntegrationTest::testUrlHelperWorksUnderNormalHttpParadigms
    Zend\ServiceManager\Exception\ServiceNotFoundException: Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for HttpViewManager

/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:496
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/Mvc/Service/ViewManagerFactory.php:32
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:853
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:983
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:598
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:557
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:481
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/Mvc/Application.php:144
/Users/mwillbanks/Projects/zf2_ZF/tests/ZendTest/View/Helper/UrlIntegrationTest.php:97

  1. ZendTest\View\Helper\UrlIntegrationTest::testUrlHelperWorksWithForceCanonicalFlag
    Zend\ServiceManager\Exception\ServiceNotFoundException: Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for HttpViewManager

/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:496
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/Mvc/Service/ViewManagerFactory.php:32
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:853
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:983
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:598
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:557
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:481
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/Mvc/Application.php:144
/Users/mwillbanks/Projects/zf2_ZF/tests/ZendTest/View/Helper/UrlIntegrationTest.php:109

  1. ZendTest\View\Helper\UrlIntegrationTest::testUrlHelperUnderConsoleParadigmShouldReturnHttpRoutes
    Zend\ServiceManager\Exception\ServiceNotFoundException: Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for ConsoleViewManager

/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:496
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/Mvc/Service/ViewManagerFactory.php:29
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:853
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:983
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:598
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:557
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/ServiceManager/ServiceManager.php:481
/Users/mwillbanks/Projects/zf2_ZF/library/Zend/Mvc/Application.php:144
/Users/mwillbanks/Projects/zf2_ZF/tests/ZendTest/View/Helper/UrlIntegrationTest.php:124

- Ensure both HttpViewManager and ConsoleViewManager factories are present
mwillbanks pushed a commit that referenced this pull request Apr 30, 2013
@mwillbanks mwillbanks merged commit 9b544f6 into zendframework:develop Apr 30, 2013
weierophinney added a commit to zendframework/zend-view that referenced this pull request May 15, 2015
- Ensure both HttpViewManager and ConsoleViewManager factories are present
gianarb pushed a commit to zendframework/zend-view that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants