added "ControllerManager" Manager, and make "ControllerLoader" as alias of it #4962

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
6 participants
Contributor

samsonasik commented Aug 14, 2013

for consistency, "ControllerLoader" should be named "ControllerManager". It not BC break because of I made new Factory named ControllerManagerFactory and point ControllerLoader as alias of ControllerManager. It can be a preparation for ZF3. When ZF3 released, the "ControllerLoader" manager can be completely removed.

Member

Ocramius commented Aug 14, 2013

@samsonasik 👍 , but you should probably also replace usages...

Contributor

samsonasik commented Aug 14, 2013

@Ocramius I replaced usages of 'ControlleLoader' to 'ControllerManager' at library and tests folder, now it is safe to remove 'ControllerLoader' from ModuleManagerFactory because of already aliased. Let me know if something missing ;)

library/Zend/Mvc/Service/ControllerManagerFactory.php
@@ -14,10 +14,10 @@
use Zend\ServiceManager\FactoryInterface;
@weierophinney

weierophinney Aug 19, 2013

Owner

It might make sense to keep a ControllerLoaderFactory in place that simply extends the ControllerManagerFactory. We would not register the factory -- but that way, if somebody was extending it, it would continue to work.

Contributor

samsonasik commented Aug 20, 2013

@weierophinney done ;)

Owner

weierophinney commented Aug 20, 2013

I'm still worried about BC implications of this.

If a developer has created a factory for ControllerLoader, the assumption is fetching the ControllerManager service will fetch that instance -- but with this change, it would not. I'm thinking we may need to bench this one until 3.0.

@samsonasik Can you post an email to the zf-contributors mailing list, pointing them to this PR and:

  • summarize what you are doing
  • explain the BC concerns
  • ask for feedback

Thanks!

Contributor

bakura10 commented Aug 20, 2013

For ZF3 I'm in favour of renaming all this mess to "ControllerPluginManager", "FilterPluginManager"... and so on =). But even, this is somewhere we're not consistent. I love using FQCN for keys, and we use it sometimes even inside the framework ('Zend\Authentication\AuthenticationService' for instance).

We need to have a consensus on that =).

library/Zend/Mvc/Controller/Plugin/Service/ForwardFactory.php
@@ -32,14 +32,14 @@ public function createService(ServiceLocatorInterface $plugins)
));
}
- if (!$services->has('ControllerLoader')) {
+ if (!$services->has('ControllerManager')) {
@Ocramius

Ocramius Aug 20, 2013

Member

Question: do we still need this check?

@samsonasik

samsonasik Aug 20, 2013

Contributor

I think no need, but changing it can be "unrelated" commit for this PR ?

library/Zend/Mvc/Service/ControllerLoaderFactory.php
-
-class ControllerLoaderFactory implements FactoryInterface
+/**
+ * @deprecated
@Ocramius

Ocramius Aug 20, 2013

Member

Add note about future removal (2.4? 3.x?)

@samsonasik

samsonasik Aug 21, 2013

Contributor

@Ocramius I have added note : "This will go away in 3.0" on the @deprecated ^^

tests/ZendTest/Mvc/Service/ControllerManagerFactoryTest.php
+use Zend\ServiceManager\ServiceManager;
+use Zend\Mvc\Exception;
+
+class ControllerManagerFactoryTest extends TestCase
@Ocramius

Ocramius Aug 20, 2013

Member

I think @covers annotations are missing here

@samsonasik

samsonasik Aug 20, 2013

Contributor

I just make a copy of ControllerLoaderFactoryTest test :D

Contributor

samsonasik commented Aug 21, 2013

@bakura10 this PR can be a preparation for ZF3, I make an alias of ControllerManager pointed to ControlletLoader to make it's still compatible with current version 2. When ZF3 released, the "ControllerLoader" manager that deprecated can be completely removed.

Contributor

devosc commented Aug 24, 2013

I'm not sure how only changing the name will benefit ZF3, when ideally its functionality should also change in order to make it an independent factory, below is along the lines of what I would like/expect to see in ZF3:

public function createService(ServiceLocatorInterface $serviceLocator)
{
    $config = $serviceLocator->get('Config');

    $controllerConfig = new ControllerManagerConfig($config['controllers']);

    $controllerManager = new ControllerManager();
    $controllerManager->setServiceLocator($serviceLocator);
    $controllerManager->addPeeringServiceManager($serviceLocator);

    $controllerConfig->configureServiceManager($controllerManager);

    if (isset($config['di']) && isset($config['di']['allowed_controllers']) && $serviceLocator->has('Di')) {
        $controllerManager->addAbstractFactory($serviceLocator->get('DiStrictAbstractServiceFactory'));
    }

    return $controllerManager;
}
Contributor

bakura10 commented Aug 24, 2013

@devosc : +100. I'm advocating using the SM config to create all plugin managers (that's what I'm doing in my ZF3 hydrator refactoring too). This will allow us to remove the infamous ModuleListener class. However we need to have a discussion about this with the team as we loose a feature (the ability to specify config in a Module.php class using the getControllerConfig method - I think it's not a big deal as people can still use the global getServiceConfig).

Changing names is just a coherency. ControllerLoader was confusing because most other plugin manager ends up with manager. At the same time we also have some plugin managers that ends with PluginManager (which is the suffix I prefer). It's all those small things that make the framework easier and more coherent to use, even if this is not a feature change.

Contributor

samsonasik commented Aug 24, 2013

@devosc This PR is for preparation for ZF3 for more consistency, just to start consistency with naming. I think the changing code can be applied when starting ZF3

Member

EvanDotPro commented Sep 2, 2013

The thread started via Nabble didn't come to my inbox, so I'll leave my comment here.

Personally, I'd rather see a ControllerManager alias added now rather than changing the class names and everything and aliasing the old to the new. Aliasing the future names to the existing names gives less risk of a BC break in 2.x. I agree with 3.x we should move toward more consistent naming, etc.

Owner

weierophinney commented Sep 3, 2013

@EvanDotPro can you clarify the specific changes you feel should be made for this PR to be ready to merge?

Contributor

samsonasik commented Sep 27, 2013

ping @EvanDotPro ^^

Owner

weierophinney commented Oct 22, 2013

@samsonasik what @EvanDotPro is indicating is:

  • Keep the original factories/services
  • Alias the future names (e.g., ControllerManager) to the present names (i.e. ControllerLoader) (I think this may be the current situation).

The rationale is it ensures BC is kept in 2.x. In 3.0, we would change the situation, and make the new name the actual service, and potentially have a "compatibility layer" that would alias the old service names to the new.

Contributor

samsonasik commented Oct 22, 2013

@weierophinney done ;), I keep the original factories, and added alias ( ControlerManager ) for it. Please let me know if I missed something. Thank you.

weierophinney added a commit that referenced this pull request Oct 23, 2013

Merge pull request #4962 from samsonasik/naming.ControllerManager
added "ControllerManager" Manager, and make "ControllerLoader" as alias of it

weierophinney added a commit that referenced this pull request Oct 23, 2013

[#4962] Updated code to use ControllerManager
- Original commit adds the alias for ControllerManager; this commit updates code
  to use that alias. Some tests needed to be updated as well.

weierophinney added a commit that referenced this pull request Oct 23, 2013

[#4962] Update README
- while not technically a BC break, should be called out in release notes

weierophinney added a commit that referenced this pull request Oct 23, 2013

@ghost ghost assigned weierophinney Oct 23, 2013

Owner

weierophinney commented Oct 23, 2013

I updated code to reference the "ControllerManager" service, including tests, and noted the change in the README. Merged to develop for release with 2.3.0.

weierophinney added a commit to zendframework/zend-test that referenced this pull request May 15, 2015

[zendframework/zendframework#4962] Updated code to use ControllerManager
- Original commit adds the alias for ControllerManager; this commit updates code
  to use that alias. Some tests needed to be updated as well.

weierophinney added a commit to zendframework/zend-test that referenced this pull request May 15, 2015

@samsonasik samsonasik deleted the samsonasik:naming.ControllerManager branch Jun 4, 2015

Contributor

samsonasik commented Jun 4, 2015

re-created in zendframework/zend-mvc#6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment