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

Class names for ServiceListenerFactory #23

Closed
weierophinney opened this issue Dec 31, 2019 · 2 comments
Closed

Class names for ServiceListenerFactory #23

weierophinney opened this issue Dec 31, 2019 · 2 comments

Comments

@weierophinney
Copy link
Member

I noticed that most services defined in the Zend\Mvc\Service\ServiceListenerFactory still use strings for the services names instead of class names.

https://github.com/zendframework/zend-mvc/blob/develop/src/Service/ServiceListenerFactory.php

It looks a little inconsequent in a factory when all services are requested by class names except the very important ViewHelperManager for example. Is there a chance to get this sorted?

Example:

namespace UserFrontend\Authorization;

use Interop\Container\ContainerInterface;
use UserModel\Permissions\UserAcl;
use Zend\Authentication\AuthenticationService;
use Zend\ServiceManager\Factory\FactoryInterface;
use Zend\View\Helper\Navigation;

class AuthorizationListenerFactory implements FactoryInterface
{
    public function __invoke(
        ContainerInterface $container,
        $requestedName,
        array $options = null
    ) {
        $viewHelperManager = $container->get('ViewHelperManager');

        $authService      = $container->get(AuthenticationService::class);
        $userAcl          = $container->get(UserAcl::class);
        $navigationHelper = $viewHelperManager->get(Navigation::class);

        $authorizationListener = new AuthorizationListener(
            $authService, $userAcl, $navigationHelper
        );

        return $authorizationListener;
    }
}

Originally posted by @RalfEggert at zendframework/zend-mvc#186

@alexmerlin
Copy link
Member

Closing issue due to being inactive for more than 1 year.

@alexmerlin alexmerlin closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants