‪TYPO3CMS  10.4
PostRepository.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
23 
30 {
32 
39  public function ‪findAllByBlog(‪Blog $blog)
40  {
41  $query = $this->‪createQuery();
42  return $query
43  ->matching(
44  $query->equals('blog', $blog)
45  )
46  ->execute();
47  }
48 
56  public function ‪findByTagAndBlog($tag, ‪Blog $blog)
57  {
58  $query = $this->‪createQuery();
59  return $query
60  ->matching(
61  $query->logicalAnd(
62  $query->equals('blog', $blog),
63  $query->equals('tags.name', $tag)
64  )
65  )
66  ->execute();
67  }
68 
75  public function ‪findRemaining(‪Post $post)
76  {
77  $blog = $post->‪getBlog();
78  $query = $this->‪createQuery();
79  return $query
80  ->matching(
81  $query->logicalAnd(
82  $query->equals('blog', $blog),
83  $query->logicalNot(
84  $query->equals('uid', $post->‪getUid())
85  )
86  )
87  )
88  ->execute();
89  }
90 
97  public function ‪findPrevious(‪Post $post)
98  {
99  $query = $this->‪createQuery();
100  return $query
101  ->matching(
102  $query->lessThan('date', $post->‪getDate())
103  )
104  ->execute()
105  ->getFirst();
106  }
107 
114  public function ‪findNext(‪Post $post)
115  {
116  $query = $this->‪createQuery();
117  return $query
118  ->matching(
119  $query->greaterThan('date', $post->‪getDate())
120  )
121  ->execute()
122  ->getFirst();
123  }
124 
132  public function ‪findRecentByBlog(‪Blog $blog, $limit = 5)
133  {
134  $query = $this->‪createQuery();
135  return $query
136  ->matching(
137  $query->equals('blog', $blog)
138  )
139  ->setLimit((int)$limit)
140  ->execute();
141  }
142 
149  public function ‪findByCategory($categoryUid)
150  {
151  $query = $this->‪createQuery();
152  return $query
153  ->matching(
154  $query->contains('categories', $categoryUid)
155  )
156  ->execute();
157  }
158 
159  public function ‪findAllSortedByCategory(array $uids)
160  {
161  $q = $this->‪createQuery();
162  $q->matching($q->in('uid', $uids));
163  $q->setOrderings([
164  'categories.title' => ‪QueryInterface::ORDER_ASCENDING,
166  ]);
167  return $q->execute();
168  }
169 }
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findRecentByBlog
‪QueryResultInterface findRecentByBlog(Blog $blog, $limit=5)
Definition: PostRepository.php:132
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getBlog
‪ExtbaseTeam BlogExample Domain Model Blog getBlog()
Definition: Post.php:121
‪TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject\getUid
‪int null getUid()
Definition: AbstractDomainObject.php:67
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findRemaining
‪QueryResultInterface findRemaining(Post $post)
Definition: PostRepository.php:75
‪TYPO3\CMS\Extbase\Persistence\QueryInterface
Definition: QueryInterface.php:29
‪TYPO3\CMS\Extbase\Persistence\QueryInterface\ORDER_DESCENDING
‪const ORDER_DESCENDING
Definition: QueryInterface.php:99
‪ExtbaseTeam\BlogExample\Domain\Repository
Definition: AdministratorRepository.php:16
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\$defaultOrderings
‪$defaultOrderings
Definition: PostRepository.php:31
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findNext
‪Post findNext(Post $post)
Definition: PostRepository.php:114
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findAllSortedByCategory
‪findAllSortedByCategory(array $uids)
Definition: PostRepository.php:159
‪TYPO3\CMS\Extbase\Persistence\QueryInterface\ORDER_ASCENDING
‪const ORDER_ASCENDING
Definition: QueryInterface.php:98
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findByCategory
‪QueryResultInterface findByCategory($categoryUid)
Definition: PostRepository.php:149
‪TYPO3\CMS\Extbase\Persistence\Repository\createQuery
‪TYPO3 CMS Extbase Persistence QueryInterface createQuery()
Definition: Repository.php:204
‪TYPO3\CMS\Extbase\Persistence\Repository
Definition: Repository.php:29
‪ExtbaseTeam\BlogExample\Domain\Model\Blog
Definition: Blog.php:27
‪ExtbaseTeam\BlogExample\Domain\Model\Post
Definition: Post.php:27
‪TYPO3\CMS\Extbase\Persistence\QueryResultInterface
Definition: QueryResultInterface.php:22
‪ExtbaseTeam\BlogExample\Domain\Model\Post\getDate
‪DateTime getDate()
Definition: Post.php:162
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findPrevious
‪Post findPrevious(Post $post)
Definition: PostRepository.php:97
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository
Definition: PostRepository.php:30
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findAllByBlog
‪QueryResultInterface findAllByBlog(Blog $blog)
Definition: PostRepository.php:39
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository\findByTagAndBlog
‪QueryResultInterface findByTagAndBlog($tag, Blog $blog)
Definition: PostRepository.php:56