Skip to content

Commit f2deb24

Browse files
committed
Fix for test errors
1 parent bdb8eca commit f2deb24

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/App/src/Service/FeedGenerator.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use DateTimeInterface;
99
use DOMDocument;
1010
use DOMElement;
11-
use Light\Blog\Enum\PostStatusEnum;
1211
use Light\Blog\Repository\PostRepository;
1312
use RuntimeException;
1413

@@ -37,10 +36,7 @@ public function getFeedFile(): string
3736

3837
public function write(): int
3938
{
40-
$posts = $this->postRepository->findBy(
41-
['status' => PostStatusEnum::Published],
42-
['postDate' => 'DESC']
43-
);
39+
$posts = $this->postRepository->getPublishedPosts();
4440

4541
$dom = new DOMDocument('1.0', 'UTF-8');
4642
$dom->formatOutput = true;

src/Blog/src/Repository/PostRepository.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,21 @@ public function getAdjacentPosts(Post $post): array
100100
return ['previous' => $previous, 'next' => $next];
101101
}
102102

103+
/**
104+
* @return array<int, Post>
105+
*/
106+
public function getPublishedPosts(): array
107+
{
108+
return $this->getQueryBuilder()
109+
->select('articles')
110+
->from(Post::class, 'articles')
111+
->where('articles.status = :published')
112+
->setParameter('published', PostStatusEnum::Published)
113+
->orderBy('articles.postDate', 'DESC')
114+
->getQuery()
115+
->getResult();
116+
}
117+
103118
/**
104119
* @return array<int, Post>
105120
*/

0 commit comments

Comments
 (0)