Reputation: 11235
What's the best way to disable the pagination? I need to see all pages and then render the view and get the rendered html. (In my case It's so slow)
$paginationAdapter = new TebipPaginatorAdapter($this->getSmsService(),$filterParams);
// Creating and configuring paginator
$paginator = new Paginator($paginationAdapter);
$paginator->setCurrentPageNumber(1);
$paginator->setItemCountPerPage(0);
$view = new \Zend\View\Model\ViewModel();
$view->setVariables($result);
$view->setTemplate('/project/sms-stats/list-sms');
$viewRender = $this->getServiceLocator()->get('ViewRenderer');
$html = $viewRender->render($view);
This line helped me to see all rendered html but it's so slow
$paginator->setItemCountPerPage(0);
Upvotes: 1
Views: 263
Reputation: 3256
I guess your adapter TebipPaginatorAdapter returns an object.
Your pagination object is very heavy.
To increase your performance you need to change your adapter to array.
http://www.webconsults.eu/blog/entry/108-What_is_a_Hydrator_in_Zend_Framework_2
Native hydrator in zend.
http://framework.zend.com/manual/2.2/en/modules/zend.stdlib.hydrator.aggregate.html
+ you need to use a cache with hydrator http://samsonasik.wordpress.com/2012/09/27/zend-framework-2-using-zendcache-and-hydratingresultset-to-save-database-resultset/
It will increase your perfomance.
public function __construct(Adapter $adapter)
{
$this->adapter = $adapter;
$this->resultSetPrototype = new HydratingResultSet();
$this->resultSetPrototype->setObjectPrototype(new Sample());
$this->initialize();
}
Transforming an Object into Array Data (extract) or the other way arround (hydrate)
namespace Zend\Stdlib\Hydrator;
interface HydratorInterface
{
/**
* Extract values from an object
*
* @param object $object
* @return array
*/
public function extract($object);
/**
* Hydrate $object with the provided $data.
*
* @param array $data
* @param object $object
* @return object
*/
public function hydrate(array $data, $object);
}
I had the same problem in Symfony, and I used hydrator + cache.
Upvotes: 1
Reputation: 16445
This question is pretty weird...
Either you want Pagination, in this case you see only a fraction of the bulk, or you do not want Pagination and in that case you'd see all entries.
If you have an Action that requires all Entries to be listed, then do NOT use Pagination, it's as simple as that.
Though in most cases i suggest to simply enable your action to take a Parameter that increases the amount of Items per Page. Listing 100 / 200 / 500 Entries as maximum on one single page should be more than enough.
Upvotes: 4