-
Notifications
You must be signed in to change notification settings - Fork 0
/
RecipeRepository.php
66 lines (54 loc) · 1.29 KB
/
RecipeRepository.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* Copyright (c) 2018 Wakers.cz
*
* @author Jiří Zapletal (http://www.wakers.cz, zapletal@wakers.cz)
*
*/
namespace Wakers\StructureModule\Repository;
use Propel\Runtime\Collection\ObjectCollection;
use Wakers\StructureModule\Database\Recipe;
use Wakers\StructureModule\Database\RecipeQuery;
class RecipeRepository
{
/**
* @param string $slug
* @return Recipe|NULL
*/
public function findOneBySlug(string $slug) : ?Recipe
{
return RecipeQuery::create()
->useRecipeSlugQuery()
->filterBySlug($slug)
->endUse()
->findOne();
}
/**
* @param int $id
* @return Recipe|NULL
*/
public function findOneById(int $id) : ?Recipe
{
return RecipeQuery::create()
->findOneById($id);
}
/**
* @return ObjectCollection|Recipe[]
*/
public function findAll() : ObjectCollection
{
return RecipeQuery::create()
->find();
}
/**
* @return ObjectCollection|Recipe[]
*/
public function findAllJoinVariables() : ObjectCollection
{
return RecipeQuery::create()
->leftJoinWithRecipeVariable()
->leftJoinWithRecipeSlug()
->orderByName()
->find();
}
}