TYPO3 CMS  TYPO3_6-2
PostRepository.php
Go to the documentation of this file.
1 <?php
20 
21  protected $defaultOrderings = array('date' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING);
22 
29  public function findAllByBlog(\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog) {
30  $query = $this->createQuery();
31  return $query
32  ->matching(
33  $query->equals('blog', $blog)
34  )
35  ->execute();
36  }
37 
45  public function findByTagAndBlog($tag, \ExtbaseTeam\BlogExample\Domain\Model\Blog $blog) {
46  $query = $this->createQuery();
47  return $query
48  ->matching(
49  $query->logicalAnd(
50  $query->equals('blog', $blog),
51  $query->equals('tags.name', $tag)
52  )
53  )
54  ->execute();
55  }
56 
63  public function findRemaining(\ExtbaseTeam\BlogExample\Domain\Model\Post $post) {
64  $blog = $post->getBlog();
65  $query = $this->createQuery();
66  return $query
67  ->matching(
68  $query->logicalAnd(
69  $query->equals('blog', $blog),
70  $query->logicalNot(
71  $query->equals('uid', $post->getUid())
72  )
73  )
74  )
75  ->execute();
76  }
77 
84  public function findPrevious(\ExtbaseTeam\BlogExample\Domain\Model\Post $post) {
85  $query = $this->createQuery();
86  return $query
87  ->matching(
88  $query->lessThan('date', $post->getDate())
89  )
90  ->execute()
91  ->getFirst();
92  }
93 
100  public function findNext(\ExtbaseTeam\BlogExample\Domain\Model\Post $post) {
101  $query = $this->createQuery();
102  return $query
103  ->matching(
104  $query->greaterThan('date', $post->getDate())
105  )
106  ->execute()
107  ->getFirst();
108  }
109 
117  public function findRecentByBlog(\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog, $limit = 5) {
118  $query = $this->createQuery();
119  return $query
120  ->matching(
121  $query->equals('blog', $blog)
122  )
123  ->setLimit((integer)$limit)
124  ->execute();
125  }
126 
133  public function findByCategory($categoryUid) {
134  $query = $this->createQuery();
135  return $query
136  ->matching(
137  $query->contains('categories', $categoryUid)
138  )
139  ->execute();
140  }
141 
142 }
143 ?>
$defaultOrderings
findNext(\ExtbaseTeam\BlogExample\Domain\Model\Post $post)
findByCategory($categoryUid)
findAllByBlog(\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog)
findByTagAndBlog($tag, \ExtbaseTeam\BlogExample\Domain\Model\Blog $blog)
findPrevious(\ExtbaseTeam\BlogExample\Domain\Model\Post $post)
findRecentByBlog(\ExtbaseTeam\BlogExample\Domain\Model\Blog $blog, $limit=5)
findRemaining(\ExtbaseTeam\BlogExample\Domain\Model\Post $post)