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