Skip to content

Commit

Permalink
Remove dependency on HtTemplateResolverModule
Browse files Browse the repository at this point in the history
  • Loading branch information
ojhaujjwal committed Aug 11, 2014
1 parent 0c35b95 commit a1509c4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ A Zend Framework 2 module to based on [Mobile-Detect](https://github.com/serbang
1. [Zend Framework 2](https://github.com/zendframework/zf2)
2. [Mobile-Detect](https://github.com/serbanghita/Mobile-Detect)
3. [zf2-mobile-detect](https://github.com/neilime/zf2-mobile-detect)
4. [HtTemplateResolverModule](https://github.com/hrevert/HtTemplateResolverModule)


# Installation
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"zendframework/zend-modulemanager": "~2.1",
"zendframework/zend-servicemanager": "~2.1",
"zendframework/zend-mvc": "~2.1",
"hrevert/ht-template-resolver-module": "0.0.*",
"neilime/zf2-mobile-detect": "1.0"
},
"autoload": {
Expand Down
19 changes: 9 additions & 10 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@

]
],
'ht_template_resolver' => [
'resolvers_plugin_manager' => [
'factories' => [
'media_map' => 'HtMobileTemplateModule\View\Resolver\Factory\MapFactory',
'media_path_stack' => 'HtMobileTemplateModule\View\Resolver\Factory\PathStackFactory',
]
'service_manager' => [
'factories' => [
'HtMobileTemplateModule\View\Resolver\Map' => 'HtMobileTemplateModule\View\Resolver\Factory\MapFactory',
'HtMobileTemplateModule\View\Resolver\PathStack' => 'HtMobileTemplateModule\View\Resolver\Factory\PathStackFactory',
],
'delegators' => [
'ViewResolver' => [
'HtMobileTemplateModule\View\Resolver\Factory\ViewResolverDelegatorFactory',
],
],
'resolvers' => [
'media_map' => 4000,
'media_path_stack' => 2000
]
]
];
5 changes: 1 addition & 4 deletions src/View/Resolver/Factory/AbstractFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ abstract class AbstractFactory implements FactoryInterface
* @param ServiceLocatorInterface $resolvers
* @return ResolverInterface
*/
public function createService(ServiceLocatorInterface $resolvers)
public function createService(ServiceLocatorInterface $serviceLocator)
{
/** @var ServiceLocatorInterface */
$serviceLocator = $resolvers->getServiceLocator();

$config = $this->getConfig($serviceLocator);

/** @var \Mobile_Detect */
Expand Down
24 changes: 24 additions & 0 deletions src/View/Resolver/Factory/ViewResolverDelegatorFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
namespace HtMobileTemplateModule\View\Resolver\Factory;

use Zend\ServiceManager\DelegatorFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\View\Resolver\AggregateResolver;

class ViewResolverDelegatorFactory implements DelegatorFactoryInterface
{
/**
* {@inheritDoc}
*
* @return AggregateResolver
*/
public function createDelegatorWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback)
{
$resolver = $callback();

$resolver->attach($serviceLocator->get('HtMobileTemplateModule\View\Resolver\Map'), 4000);
$resolver->attach($serviceLocator->get('HtMobileTemplateModule\View\Resolver\PathStack'), 2000);

return $resolver;
}
}

0 comments on commit a1509c4

Please sign in to comment.