This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/view-resolver-services' of https://github.com/E…
…vanDotPro/zf2 into feature/mvc-view-resolver-factories Conflicts: library/Zend/Mvc/Service/ModuleManagerFactory.php
- Loading branch information
Showing
5 changed files
with
143 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_Mvc | ||
*/ | ||
|
||
namespace Zend\Mvc\Service; | ||
|
||
use Zend\View\Resolver as ViewResolver; | ||
use Zend\ServiceManager\FactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_Mvc | ||
* @subpackage Service | ||
*/ | ||
class ViewResolverFactory implements FactoryInterface | ||
{ | ||
/** | ||
* Create the aggregate view resolver | ||
* | ||
* Creates a Zend\View\Resolver\AggregateResolver and attaches the template | ||
* map resolver and path stack resolver | ||
* | ||
* @param ServiceLocatorInterface $serviceLocator | ||
* @return ViewResolverAggregateResolver | ||
*/ | ||
public function createService(ServiceLocatorInterface $serviceLocator) | ||
{ | ||
$resolver = new ViewResolver\AggregateResolver(); | ||
$resolver->attach($serviceLocator->get('ViewTemplateMapResolver')); | ||
$resolver->attach($serviceLocator->get('ViewTemplatePathStack')); | ||
return $resolver; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
library/Zend/Mvc/Service/ViewTemplateMapResolverFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_Mvc | ||
*/ | ||
|
||
namespace Zend\Mvc\Service; | ||
|
||
use Zend\View\Resolver as ViewResolver; | ||
use Zend\ServiceManager\FactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_Mvc | ||
* @subpackage Service | ||
*/ | ||
class ViewTemplateMapResolverFactory implements FactoryInterface | ||
{ | ||
/** | ||
* Create the template map view resolver | ||
* | ||
* Creates a Zend\View\Resolver\AggregateResolver and populates it with the | ||
* ['view_manager']['template_map'] | ||
* | ||
* @param ServiceLocatorInterface $serviceLocator | ||
* @return ViewResolver\TemplateMapResolver | ||
*/ | ||
public function createService(ServiceLocatorInterface $serviceLocator) | ||
{ | ||
$config = $serviceLocator->get('Config'); | ||
$config = $config['view_manager']; | ||
$map = array(); | ||
if (isset($config['template_map'])) { | ||
$map = $config['template_map']; | ||
} | ||
return new ViewResolver\TemplateMapResolver($map); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_Mvc | ||
*/ | ||
|
||
namespace Zend\Mvc\Service; | ||
|
||
use Zend\View\Resolver as ViewResolver; | ||
use Zend\ServiceManager\FactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_Mvc | ||
* @subpackage Service | ||
*/ | ||
class ViewTemplatePathStackFactory implements FactoryInterface | ||
{ | ||
/** | ||
* Create the template map view resolver | ||
* | ||
* Creates a Zend\View\Resolver\TemplatePathStack and populates it with the | ||
* ['view_manager']['template_path_stack'] | ||
* | ||
* @param ServiceLocatorInterface $serviceLocator | ||
* @return ViewResolver\TemplatePathStack | ||
*/ | ||
public function createService(ServiceLocatorInterface $serviceLocator) | ||
{ | ||
$config = $serviceLocator->get('Config'); | ||
$config = $config['view_manager']; | ||
$stack = array(); | ||
if (isset($config['template_path_stack'])) { | ||
$stack = $config['template_path_stack']; | ||
} | ||
$templatePathStack = new ViewResolver\TemplatePathStack(); | ||
$templatePathStack->addPaths($stack); | ||
return $templatePathStack; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters