ZF2-24: "static function factory" & PluginBroker
I found a issue about ZF2's plugin architecture.
At present, some components provides the static factory method, of course, these are upgraded by upgrade of the loader, (From ZF1's pluingLoader to ZF2's PluginBroker)
For example, at Paginator.
$pluginLoader = self::getAdapterLoader(); $adapterClassName = $pluginLoader->load($adapter); return new self(new $adapterClassName($data));
$broker = self::getAdapterBroker(); $adapter = $broker->load($adapter, array($data)); return new self($adapter);
Had making change above. However, in the case of this ZF2,
Loaded the adapter object at the point of above.
So, adapter name object which once loaded will use the first data with or without cause those data is different.
var_dump(count(Paginator\Paginator::factory(5)->getAdapter())); // 5 var_dump(count(Paginator\Paginator::factory(6)->getAdapter())); // 5
If you run Paginator's unittest-code, you can find where it fails actually.
Point to be a problem is,"static function factory()" would use an adapter object that is generated first.I think, the Object generated by "factory" method are considered to be absolutely new.