‪TYPO3CMS  9.5
PostRepository.php
Go to the documentation of this file.
1 <?php
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 
20 
27 {
29 
36  public function ‪findAllByBlog(\‪ExtbaseTeam\BlogExample\Domain\Model\Blog $blog)
37  {
38  $query = $this->‪createQuery();
39  return $query
40  ->matching(
41  $query->equals('blog', $blog)
42  )
43  ->execute();
44  }
45 
53  public function ‪findByTagAndBlog($tag, \‪ExtbaseTeam\BlogExample\Domain\Model\Blog $blog)
54  {
55  $query = $this->‪createQuery();
56  return $query
57  ->matching(
58  $query->logicalAnd(
59  $query->equals('blog', $blog),
60  $query->equals('tags.name', $tag)
61  )
62  )
63  ->execute();
64  }
65 
72  public function ‪findRemaining(‪Post $post)
73  {
74  $blog = $post->‪getBlog();
75  $query = $this->‪createQuery();
76  return $query
77  ->matching(
78  $query->logicalAnd(
79  $query->equals('blog', $blog),
80  $query->logicalNot(
81  $query->equals('uid', $post->‪getUid())
82  )
83  )
84  )
85  ->execute();
86  }
87 
94  public function ‪findPrevious(‪Post $post)
95  {
96  $query = $this->‪createQuery();
97  return $query
98  ->matching(
99  $query->lessThan('date', $post->‪getDate())
100  )
101  ->execute()
102  ->getFirst();
103  }
104 
111  public function ‪findNext(‪Post $post)
112  {
113  $query = $this->‪createQuery();
114  return $query
115  ->matching(
116  $query->greaterThan('date', $post->‪getDate())
117  )
118  ->execute()
119  ->getFirst();
120  }
121 
129  public function ‪findRecentByBlog(\‪ExtbaseTeam\BlogExample\Domain\Model\Blog $blog, $limit = 5)
130  {
131  $query = $this->‪createQuery();
132  return $query
133  ->matching(
134  $query->equals('blog', $blog)
135  )
136  ->setLimit((int)$limit)
137  ->execute();
138  }
139 
146  public function ‪findByCategory($categoryUid)
147  {
148  $query = $this->‪createQuery();
149  return $query
150  ->matching(
151  $query->contains('categories', $categoryUid)
152  )
153  ->execute();
154  }
155 
156  public function ‪findAllSortedByCategory(array $uids)
157  {
158  $q = $this->‪createQuery();
159  $q->matching($q->in('uid', $uids));
160  $q->setOrderings([
161  'categories.title' => ‪QueryInterface::ORDER_ASCENDING,
163  ]);
164  return $q->execute();
165  }
166 }
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getBlog
‪ExtbaseTeam BlogExample Domain Model Blog getBlog()
Definition: Post.php:117
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findRemaining
‪QueryResultInterface findRemaining(Post $post)
Definition: PostRepository.php:72
‪TYPO3\CMS\Extbase\Persistence\QueryInterface
Definition: QueryInterface.php:26
‪TYPO3\CMS\Extbase\Persistence\QueryInterface\ORDER_DESCENDING
‪const ORDER_DESCENDING
Definition: QueryInterface.php:96
‪ExtbaseTeam\BlogExample\Domain\Repository
Definition: AdministratorRepository.php:2
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findByTagAndBlog
‪QueryResultInterface findByTagAndBlog($tag, \ExtbaseTeam\BlogExample\Domain\Model\Blog $blog)
Definition: PostRepository.php:53
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\$defaultOrderings
‪$defaultOrderings
Definition: PostRepository.php:28
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findNext
‪Post findNext(Post $post)
Definition: PostRepository.php:111
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findAllSortedByCategory
‪findAllSortedByCategory(array $uids)
Definition: PostRepository.php:156
‪TYPO3\CMS\Extbase\Persistence\QueryInterface\ORDER_ASCENDING
‪const ORDER_ASCENDING
Definition: QueryInterface.php:95
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findByCategory
‪QueryResultInterface findByCategory($categoryUid)
Definition: PostRepository.php:146
‪TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject\getUid
‪int getUid()
Definition: AbstractDomainObject.php:62
‪TYPO3\CMS\Extbase\Persistence\Repository\createQuery
‪TYPO3 CMS Extbase Persistence QueryInterface createQuery()
Definition: Repository.php:189
‪TYPO3\CMS\Extbase\Persistence\Repository
Definition: Repository.php:23
‪ExtbaseTeam\BlogExample\Domain\Model\Post
Definition: Post.php:23
‪TYPO3\CMS\Extbase\Persistence\QueryResultInterface
Definition: QueryResultInterface.php:21
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getDate
‪DateTime getDate()
Definition: Post.php:158
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findRecentByBlog
‪QueryResultInterface findRecentByBlog(\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog, $limit=5)
Definition: PostRepository.php:129
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findPrevious
‪Post findPrevious(Post $post)
Definition: PostRepository.php:94
‪ExtbaseTeam
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository
Definition: PostRepository.php:27
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findAllByBlog
‪QueryResultInterface findAllByBlog(\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog)
Definition: PostRepository.php:36