Revert "[CLEANUP] Rework/simplify copyright header and remove @package"
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Be / Widget / PaginateViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Be\Widget;
3
4 /* *
5 * It is free software; you can redistribute it and/or modify it under *
6 * the terms of the GNU Lesser General Public License, either version 3 *
7 * of the License, or (at your option) any later version. *
8 * *
9 * *
10 * This script is distributed in the hope that it will be useful, but *
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
12 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
13 * General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU Lesser General Public *
16 * License along with the script. *
17 * If not, see http://www.gnu.org/licenses/lgpl.html *
18 * *
19 * The TYPO3 project - inspiring people to share! *
20 * */
21 /**
22 * This ViewHelper renders a Pagination of objects for the TYPO3 Backend.
23 *
24 * = Examples =
25 *
26 * <code title="required arguments">
27 * <f:be.widget.paginate objects="{blogs}" as="paginatedBlogs">
28 * use {paginatedBlogs} as you used {blogs} before, most certainly inside
29 * a <f:for> loop.
30 * </f:be.widget.paginate>
31 * </code>
32 *
33 * <code title="full configuration">
34 * <f:be.widget.paginate objects="{blogs}" as="paginatedBlogs" configuration="{itemsPerPage: 5, insertAbove: 1, insertBelow: 0, recordsLabel: 'MyRecords'}">
35 * use {paginatedBlogs} as you used {blogs} before, most certainly inside
36 * a <f:for> loop.
37 * </f:be.widget.paginate>
38 * The recordsLabel can be used to replace the text in "Records 1 - 99" with a label of your own choice
39 * </code>
40 *
41 * = Performance characteristics =
42 *
43 * In the above examples, it looks like {blogs} contains all Blog objects, thus
44 * you might wonder if all objects were fetched from the database.
45 * However, the blogs are NOT fetched from the database until you actually use them,
46 * so the paginate ViewHelper will adjust the query sent to the database and receive
47 * only the small subset of objects.
48 * So, there is no negative performance overhead in using the Be Paginate Widget.
49 *
50 * @api
51 */
52 class PaginateViewHelper extends \TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetViewHelper {
53
54 /**
55 * @var \TYPO3\CMS\Fluid\ViewHelpers\Be\Widget\Controller\PaginateController
56 * @inject
57 */
58 protected $controller;
59
60 /**
61 * @param \TYPO3\CMS\Extbase\Persistence\QueryResultInterface $objects
62 * @param string $as
63 * @param array $configuration
64 * @return string
65 */
66 public function render(\TYPO3\CMS\Extbase\Persistence\QueryResultInterface $objects, $as, array $configuration = array('itemsPerPage' => 10, 'insertAbove' => FALSE, 'insertBelow' => TRUE, 'recordsLabel' => '')) {
67 return $this->initiateSubRequest();
68 }
69 }