/** * Forgery constructor * * @param \Magelight\Db\Collection $visitorsCollection * @param int $currentPage */ public function __forge(\Magelight\Db\Collection $visitorsCollection, $currentPage = 0) { $this->collection = $visitorsCollection; $this->currentPage = $currentPage; $this->collection->setPage($currentPage); $total = 0; $this->visitors = $this->collection->fetchAll(true, $total); $this->total = $total; $this->sectionAppend('visitors-pager', $this->getPagerBlock()); }
/** * Visitors controller index action */ public function indexAction() { $this->breadcrumbsBlock->addBreadcrumb('Visitors', 'admin/visitors'); $collection = \Magelight\Db\Collection::forge(\Magelight\Visitors\Models\Visitor::orm()->orderByDesc('time'))->setLimit(30); $page = $this->request()->getRequest('page', 0); $this->view()->sectionReplace('content', \Magelight\Visitors\Blocks\VisitorsList::forge($collection, $page)); $this->renderView(); }
/** * Set pager current page * * @param int $currentPage * @return Pager */ public function setCurrentPage($currentPage = 0) { if ($this->collection instanceof \Magelight\Db\Collection) { $this->collection->setPage($currentPage); } $this->currentPage = $currentPage; return $this; }
/** * Get entity collection * * @return \Magelight\Db\Collection */ public function getCollection() { return \Magelight\Db\Collection::forge($this->scaffold->getEntityModel($this->entity)->getOrm())->setLimit(10)->setPage($this->page); }
public function testGetFlatCollection() { $collectionMock = $this->getMock(\Magelight\Db\Collection::class, [], [], '', false); \Magelight\Db\Collection::forgeMock($collectionMock); $this->assertEquals($collectionMock, \Magelight\Model::getFlatCollection()); }
/** * Get models flat collection * * @return Db\Collection */ public static function getFlatCollection() { return \Magelight\Db\Collection::forge(static::callStaticLate('orm')); }