In Zend Framework 2 it's quite easy to use a custom class instead of an invocable one from the framework. E.g. a ViewHelper
:
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',
),
),
);
}
}
Now I'm having a problem with a bug in the Zend\Paginator\Adapter\DbSelect
. It has already been fixed, but the fix has not been merged to the master
branch yet. Anyway, I want to switch temporarily to my own DbSelect
class. But DbSelect
is not invocable
. How to use a custom class insteead of a default framework class, e.g. Zend\Paginator\Adapter\DbSelect
?