Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move AsseticBundle\Configuration to its own factory #168

Merged
merged 7 commits into from
Feb 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

class Module implements
AutoloaderProviderInterface,
ConfigProviderInterface,
BootstrapListenerInterface,
ServiceProviderInterface
BootstrapListenerInterface
{
/**
* Listen to the bootstrap event
Expand Down Expand Up @@ -43,25 +40,6 @@ public function getConfig()
return require __DIR__ . '/configs/module.config.php';
}

/**
* Expected to return \Zend\ServiceManager\Config object or array to
* seed such an object.
*
* @return array|\Zend\ServiceManager\Config
*/
public function getServiceConfig()
{
return [
'factories' => [
'AsseticBundle\Configuration' => function (ServiceLocatorInterface $serviceLocator) {
$configuration = $serviceLocator->get('Configuration');

return new Configuration($configuration['assetic_configuration']);
}
],
];
}

/**
* Return an array for passing to Zend\Loader\AutoloaderFactory.
*
Expand Down
1 change: 1 addition & 0 deletions configs/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'Assetic\AssetManager' => 'Zend\ServiceManager\Factory\InvokableFactory',
'AsseticBundle\Listener' => 'Zend\ServiceManager\Factory\InvokableFactory',
'AsseticBundle\Cli' => 'AsseticBundle\Cli\ApplicationFactory',
'AsseticBundle\Configuration' => 'AsseticBundle\Factory\ConfigurationFactory',
],
],

Expand Down
17 changes: 17 additions & 0 deletions src/AsseticBundle/Factory/ConfigurationFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace AsseticBundle\Factory;

use AsseticBundle\Configuration;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Factory\FactoryInterface;

class ConfigurationFactory implements FactoryInterface
{
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$configuration = $container->get('Configuration');

return new Configuration($configuration['assetic_configuration']);
}
}