Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Removing $class->newInstanceArgs($this->creationOptions) from Zend\Paginator\Adapter\Service\DbSelectFactory #6403

Closed
samsonasik opened this issue Jun 22, 2014 · 11 comments

Comments

@samsonasik
Copy link
Contributor

Hello,

I've seen that there is a Zend\Paginator\Adapter\Service\DbSelectFactory that use $class->newInstanceArgs($this->creationOptions).

I've seen the ML for it as @weierophinney statement : http://zend-framework-community.634137.n4.nabble.com/AbstractPluginManager-amp-options-creationOptions-will-not-work-as-newInstanceArgs-td4656077.html#a4656083 that newInstanceArgs is no longer used for plugin architecture.

is it should be removed ? or the factory class Zend\Paginator\Adapter\Service\DbSelectFactory should be removed and the Zend\Paginator\AdapterPluginManager should be removed too because the call via $invokableClasses is not implementable because the adapters ( arrayadapter, nulladapter, etc) passed parameter to the __construct , and there is no other function to set the parameter instead of __construct ?

I created a post on the ML at http://zend-framework-community.634137.n4.nabble.com/Removing-class-gt-newInstanceArgs-this-gt-creationOptions-from-Zend-Paginator-Adapter-Service-DbSeley-td4662167.html , I've subcribed to it but not approved yet.

Thank you.

@Ocramius
Copy link
Member

@samsonasik an alternate would be to use a plugin manager, but that would be overkill. I'm not sure if I understand the actual problem being exposed though.

@samsonasik
Copy link
Contributor Author

@Ocramius using pluginmanager is not used here too, because :

   $this->getServiceLocator()
       ->get('PaginatorPluginManager')->get('dbselect');

will comes with error because not set yet, and the other invokables classes ( Zend\Paginator\Adapter\ArrayAdapter|Callback|Iterator|Null) that registered at the PaginatorPluginManager are need to pass parameter into constructor too. What if we remove the PluginManager and the adapter service ?

samsonasik added a commit to samsonasik/zf2 that referenced this issue Jun 26, 2014
@samsonasik
Copy link
Contributor Author

@Ocramius please check my branch commit diff samsonasik@3e798ae , if it is ok, then I will submit a PR .... Thank you.

@Ocramius
Copy link
Member

@samsonasik that's sadly not ok until 3.x, as you are removing functionality. It may be acceptable, but a quick search on usage of that plugin manager may be needed first.

Ping @weierophinney is the breakage acceptable in 2.x for you?

@Ocramius Ocramius reopened this Jun 26, 2014
@Ocramius
Copy link
Member

Whoops, sorry, closed by mistake.

@samsonasik
Copy link
Contributor Author

I've got the solution for it by passing 2 parameter into get() function on PluginManager :

$this->getServiceLocator()
        ->get('PaginatorPluginManager')->get('dbselect', array($select, $adapter));

But as @weierophinney said that "newInstanceArgs" is no longer used, so, @Ocramius how about changing DbSelectFactory::createService() with :

        return new \Zend\Paginator\Adapter\DbSelect(
            $this->creationOptions[0],
            $this->creationOptions[1],
            isset($this->creationOptions[2]) ? : null
        );

?
If it is ok, then I will create a PR for it.

samsonasik added a commit to samsonasik/zf2 that referenced this issue Aug 13, 2014
@Ocramius
Copy link
Member

👍

@samsonasik
Copy link
Contributor Author

@Ocramius done, created PR #6574 for it.

@Ocramius Ocramius added this to the 2.4.0 milestone Aug 14, 2014
@Ocramius Ocramius self-assigned this Aug 14, 2014
@Ocramius
Copy link
Member

@samsonasik thanks!

samsonasik added a commit to samsonasik/zf2 that referenced this issue Sep 28, 2014
Ocramius added a commit that referenced this issue Nov 22, 2014
Ocramius added a commit that referenced this issue Nov 22, 2014
Ocramius added a commit that referenced this issue Nov 22, 2014
@Ocramius
Copy link
Member

Handled in #6574

gianarb pushed a commit to zendframework/zend-paginator that referenced this issue May 15, 2015
gianarb pushed a commit to zendframework/zend-paginator that referenced this issue May 15, 2015
gianarb pushed a commit to zendframework/zend-paginator that referenced this issue May 15, 2015
gianarb pushed a commit to zendframework/zend-paginator that referenced this issue May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants