AbstractRepository.php 1.7 KB
Newer Older
1
<?php
2 3
namespace T3o\TerFe2\Domain\Repository;

4 5
/*
 * This file is part of the TYPO3 CMS project.
flyguide's avatar
flyguide committed
6
 *
7 8 9
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
flyguide's avatar
flyguide committed
10
 *
11 12
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
flyguide's avatar
flyguide committed
13
 *
14 15
 * The TYPO3 project - inspiring people to share!
 */
flyguide's avatar
flyguide committed
16 17 18 19

/**
 * Abstract repository
 */
20
abstract class AbstractRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
21
{
22

23 24 25
    /**
     * Returns a query for objects of this repository
     *
26 27
     * @param int $offset Offset to start with
     * @param int $count Count of result
28
     * @param array $ordering Ordering <-> Direction
29
     * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
30
     */
31
    public function createQuery($offset = 0, $count = 0, array $ordering = [])
32 33
    {
        $query = parent::createQuery();
34

35 36 37
        if (!empty($offset)) {
            $query->setOffset((int)$offset);
        }
38

39 40 41
        if (!empty($count)) {
            $query->setLimit((int)$count);
        }
42

43 44 45
        if (!empty($ordering)) {
            $query->setOrderings($ordering);
        }
46

47 48
        return $query;
    }
49

50 51 52
    /**
     * Returns all objects
     *
53 54 55 56
     * @param int $offset Offset to start with
     * @param int $count Count of result
     * @param array $ordering Ordering <-> Direction
     * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface Objects
57
     */
58
    public function findAll($offset = 0, $count = 0, array $ordering = [])
59 60 61 62
    {
        $query = $this->createQuery($offset, $count, $ordering);
        return $query->execute();
    }
flyguide's avatar
flyguide committed
63
}