protected function setPagination(AgaviRequestDataHolder $request_data, array $settings = [])
 {
     $number_of_results = $this->getAttribute('number_of_results', 0);
     $list_config = $request_data->getParameter('list_config');
     $offset = $list_config->getOffset();
     $limit_per_page = $list_config->getLimit();
     $pagination = Pagination::createByOffset($number_of_results, $limit_per_page, $offset);
     $this->setAttributes($pagination->toArray());
     $rendered_pagination = $this->renderSubject($pagination, $settings);
     $this->setAttribute('rendered_pagination', $rendered_pagination);
     return $rendered_pagination;
 }
Esempio n. 2
0
 public function testCreateByOffsetWithNullValueArguments()
 {
     $results = null;
     $limit = null;
     $offset = null;
     $pagination = Pagination::createByOffset($results, $limit, $offset);
     $this->assertInstanceOf('Honeybee\\Ui\\ValueObjects\\Pagination', $pagination);
     $this->assertEquals(1, $pagination->getCurrentPageNumber(), 'current page number should be 1');
     $this->assertEquals(0, $pagination->getCurrentPageOffset(), 'current page offset should be correct');
     $this->assertEquals(0, $pagination->getPrevPageOffset(), 'previous page offset should be correct');
     $this->assertEquals(0, $pagination->getNextPageOffset(), 'next page offset should be correct');
     $this->assertTrue($pagination->isFirstPage(), 'current page should be first page');
     $this->assertTrue($pagination->isLastPage(), 'current page should be last page');
     $this->assertFalse($pagination->hasNextPage(), 'current page should have no next page');
     $this->assertFalse($pagination->hasPrevPage(), 'current page should have no previous page');
 }