0

Zend Framework 2 provides a possibility to use custom classes instead of a invokables delivered with the framework. E.g. ViewHelper classes:

namespace Application;

...

class Module {

    public function onBootstrap(MvcEvent $mvcEvent) {
        $application = $mvcEvent->getApplication();
        $serviceManager = $application->getServiceManager();
        $viewHelperManager = $serviceManager->get('ViewHelperManager');
        $viewHelperManager->setInvokableClass('headmeta', 'MyNamespace\View\Helper\HeadMeta');
    }

    ...

    public function getAutoloaderConfig() {
        return array(
            ...
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                    'MyNamespace' => __DIR__ . '/../../vendor/MyNamespace/library/MyNamespace',
                ),
            ),
        );
    }

}

So, all invocables (particularly the ViewHelpers) can be replaced. What else? Is there a list of types of classes, that can be replaced by custom ones the way like invokables (using the ServiceManager / EventManager)?

edigu
  • 9,878
  • 5
  • 57
  • 80
automatix
  • 14,018
  • 26
  • 105
  • 230

1 Answers1

0

I guess everything that ends up 'in' the service/plugin manager can be substituted. You can checkup places like controller, view or form element plugin manager classes. You could also try to dump the whole service manager object and see what keys it holds and try to overwrite them in your Module class (using the same service class as the original, e.g. overwriting a factory created service with another factory).

guessimtoolate
  • 8,372
  • 2
  • 18
  • 26