[CLEANUP] Rework/simplify copyright header and remove @package
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Widget / PaginateViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Widget;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is backported from the TYPO3 Flow package "TYPO3.Fluid".
8 *
9 * It is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, either version 2
11 * of the License, or any later version.
12 *
13 * For the full copyright and license information, please read the
14 * LICENSE.txt file that was distributed with this source code.
15 *
16 * The TYPO3 project - inspiring people to share!
17 */
18
19 use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
20 use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
21 use TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetViewHelper;
22
23 /**
24 * This ViewHelper renders a Pagination of objects.
25 *
26 * = Examples =
27 *
28 * <code title="required arguments">
29 * <f:widget.paginate objects="{blogs}" as="paginatedBlogs">
30 * use {paginatedBlogs} as you used {blogs} before, most certainly inside
31 * a <f:for> loop.
32 * </f:widget.paginate>
33 * </code>
34 *
35 * <code title="full configuration">
36 * <f:widget.paginate objects="{blogs}" as="paginatedBlogs" configuration="{itemsPerPage: 5, insertAbove: 1, insertBelow: 0, maximumNumberOfLinks: 10}">
37 * use {paginatedBlogs} as you used {blogs} before, most certainly inside
38 * a <f:for> loop.
39 * </f:widget.paginate>
40 * </code>
41 *
42 * = Performance characteristics =
43 *
44 * In the above examples, it looks like {blogs} contains all Blog objects, thus
45 * you might wonder if all objects were fetched from the database.
46 * However, the blogs are NOT fetched from the database until you actually use them,
47 * so the paginate ViewHelper will adjust the query sent to the database and receive
48 * only the small subset of objects.
49 * So, there is no negative performance overhead in using the Paginate Widget.
50 *
51 * @api
52 */
53 class PaginateViewHelper extends \TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetViewHelper {
54
55 /**
56 * @var \TYPO3\CMS\Fluid\ViewHelpers\Widget\Controller\PaginateController
57 * @inject
58 */
59 protected $controller;
60
61 /**
62 * @param \TYPO3\CMS\Extbase\Persistence\QueryResultInterface $objects
63 * @param string $as
64 * @param array $configuration
65 * @return string
66 */
67 public function render(\TYPO3\CMS\Extbase\Persistence\QueryResultInterface $objects, $as, array $configuration = array('itemsPerPage' => 10, 'insertAbove' => FALSE, 'insertBelow' => TRUE, 'maximumNumberOfLinks' => 99)) {
68 return $this->initiateSubRequest();
69 }
70 }