1

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?

automatix
  • 14,018
  • 26
  • 105
  • 230
  • The issue you mentioned already fixed and merged in [#6817](https://github.com/zendframework/zf2/pull/6817) – edigu Feb 19 '15 at 21:38
  • Thank you for your comment! Well, the question is not only about this concrete issue. But anyway -- I've just made a `composer update`, that has loaded the current ZF2 release `2.3.5`. I don't know why, but the code of `Zend\Paginator\Adapter\DbSelect` at the problematical place is stil staying as it was before the fix: line `90` contains only a `return` direction (`return $resultSet;`) without any check and transformation to array (see fix https://github.com/samsonasik/zf2/commit/cf7abbf47151570a0322fa78c3f04353aa6e49d6#diff-2311891e6ba82bfdd1f0f3c0dcf45fd5R90). – automatix Feb 19 '15 at 22:58

1 Answers1

0

Paginator has its own adapter plugin manager. So you can push to him your own dbselect factory.

venca
  • 1,196
  • 5
  • 18