Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Allow to add serializers through config #3572

Merged
merged 1 commit into from

2 participants

@bakura10

This allow to add serializers to the SerializerAdapter plugin manager the same way as many other ZF 2 components. Basically, you can either implement SerializerProviderInterface in your module class, or adding the serializers key in your config array.

@weierophinney > Could you merge this for 2.1 plz ? Btw, in this PR I've done what I told you about previous time (moving the service listener stuff into the own manager factory). If it's ok for you I'll do this for all others plugin managers once ZF 2.1 is out.

@weierophinney weierophinney merged commit ae45095 into zendframework:develop
@bakura10 bakura10 deleted the bakura10:serializer-feature branch
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'feature/3572' into develop
Close #3572
c7e4345
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-modulemanager
@weierophinney weierophinney Merge branch 'feature/3572' into develop 936ef51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 27, 2013
  1. @bakura10
This page is out of date. Refresh to see the latest.
View
18 library/Zend/ModuleManager/Feature/SerializerProviderInterface.php
@@ -0,0 +1,18 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+namespace Zend\ModuleManager\Feature;
+
+interface SerializerProviderInterface
+{
+ /**
+ * @return array
+ */
+ public function getSerializerConfig();
+}
View
38 library/Zend/Mvc/Service/SerializerAdapterPluginManagerFactory.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+namespace Zend\Mvc\Service;
+
+use Zend\ServiceManager\ServiceLocatorInterface;
+
+class SerializerAdapterPluginManagerFactory extends AbstractPluginManagerFactory
+{
+ const PLUGIN_MANAGER_CLASS = 'Zend\Serializer\AdapterPluginManager';
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public function createService(ServiceLocatorInterface $serviceLocator)
+ {
+ /** @var $serviceListener \Zend\ModuleManager\Listener\ServiceListener */
+ $serviceListener = $serviceLocator->get('ServiceListener');
+
+ // This will allow to register new serializers easily, either by implementing the SerializerProviderInterface
+ // in your Module.php file, or by adding the "serializers" key in your module.config.php file
+ $serviceListener->addServiceManager(
+ $serviceLocator,
+ 'serializers',
+ 'Zend\ModuleManager\Feature\SerializerProviderInterface',
+ 'getSerializerConfig'
+ );
+
+ return parent::createService($serviceLocator);
+ }
+}
Something went wrong with that request. Please try again.