TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
PostRepository.php
Go to the documentation of this file.
1 <?php
2 namespace ExtbaseTeam\BlogExample\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 
23 {
25 
32  public function findAllByBlog(\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog)
33  {
34  $query = $this->createQuery();
35  return $query
36  ->matching(
37  $query->equals('blog', $blog)
38  )
39  ->execute();
40  }
41 
49  public function findByTagAndBlog($tag, \ExtbaseTeam\BlogExample\Domain\Model\Blog $blog)
50  {
51  $query = $this->createQuery();
52  return $query
53  ->matching(
54  $query->logicalAnd(
55  $query->equals('blog', $blog),
56  $query->equals('tags.name', $tag)
57  )
58  )
59  ->execute();
60  }
61 
68  public function findRemaining(\ExtbaseTeam\BlogExample\Domain\Model\Post $post)
69  {
70  $blog = $post->getBlog();
71  $query = $this->createQuery();
72  return $query
73  ->matching(
74  $query->logicalAnd(
75  $query->equals('blog', $blog),
76  $query->logicalNot(
77  $query->equals('uid', $post->getUid())
78  )
79  )
80  )
81  ->execute();
82  }
83 
90  public function findPrevious(\ExtbaseTeam\BlogExample\Domain\Model\Post $post)
91  {
92  $query = $this->createQuery();
93  return $query
94  ->matching(
95  $query->lessThan('date', $post->getDate())
96  )
97  ->execute()
98  ->getFirst();
99  }
100 
107  public function findNext(\ExtbaseTeam\BlogExample\Domain\Model\Post $post)
108  {
109  $query = $this->createQuery();
110  return $query
111  ->matching(
112  $query->greaterThan('date', $post->getDate())
113  )
114  ->execute()
115  ->getFirst();
116  }
117 
125  public function findRecentByBlog(\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog, $limit = 5)
126  {
127  $query = $this->createQuery();
128  return $query
129  ->matching(
130  $query->equals('blog', $blog)
131  )
132  ->setLimit((int)$limit)
133  ->execute();
134  }
135 
142  public function findByCategory($categoryUid)
143  {
144  $query = $this->createQuery();
145  return $query
146  ->matching(
147  $query->contains('categories', $categoryUid)
148  )
149  ->execute();
150  }
151 }
findByCategory($categoryUid)
findRemaining(\ExtbaseTeam\BlogExample\Domain\Model\Post $post)
findAllByBlog(\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog)
findRecentByBlog(\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog, $limit=5)
$defaultOrderings
findByTagAndBlog($tag,\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog)
findNext(\ExtbaseTeam\BlogExample\Domain\Model\Post $post)
findPrevious(\ExtbaseTeam\BlogExample\Domain\Model\Post $post)