[!!!][TASK] Use native trigger_error and ErrorHandler for deprecations
[Packages/TYPO3.CMS.git] / typo3 / sysext / sys_note / Classes / Domain / Repository / SysNoteRepository.php
1 <?php
2 namespace TYPO3\CMS\SysNote\Domain\Repository;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18
19 /**
20 * Sys_note repository
21 */
22 class SysNoteRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
23 {
24 /**
25 * Initialize the repository
26 */
27 public function initializeObject()
28 {
29 $querySettings = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class);
30 $querySettings->setRespectStoragePage(false);
31 $this->setDefaultQuerySettings($querySettings);
32 }
33
34 /**
35 * Find notes by given pids and author
36 *
37 * @param string $pids Single PID or comma separated list of PIDs
38 * @param \TYPO3\CMS\Extbase\Domain\Model\BackendUser $author The author
39 * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
40 * @deprecated
41 */
42 public function findByPidsAndAuthor($pids, \TYPO3\CMS\Extbase\Domain\Model\BackendUser $author)
43 {
44 trigger_error('Method findByPidsAndAuthor() is deprecated since v9 and will be removed with v10', E_USER_DEPRECATED);
45 $pids = GeneralUtility::intExplode(',', (string)$pids);
46 $query = $this->createQuery();
47 $query->setOrderings([
48 'sorting' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
49 'creationDate' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
50 ]);
51 $query->matching(
52 $query->logicalAnd(
53 $query->in('pid', $pids),
54 $query->logicalOr(
55 $query->equals('personal', 0),
56 $query->equals('author', $author)
57 )
58 )
59 );
60 return $query->execute();
61 }
62
63 /**
64 * Find notes by given pids and author
65 *
66 * @param string $pids Single PID or comma separated list of PIDs
67 * @param int $author author uid
68 * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
69 */
70 public function findByPidsAndAuthorId($pids, int $author)
71 {
72 $pids = GeneralUtility::intExplode(',', (string)$pids);
73 $query = $this->createQuery();
74 $query->setOrderings([
75 'sorting' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
76 'creationDate' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
77 ]);
78 $query->matching(
79 $query->logicalAnd(
80 $query->in('pid', $pids),
81 $query->logicalOr(
82 $query->equals('personal', 0),
83 $query->equals('author', $author)
84 )
85 )
86 );
87 return $query->execute();
88 }
89 }