1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace App\Blog; |
||
6 | |||
7 | use Cycle\ORM\ORMInterface; |
||
8 | use Cycle\ORM\Select; |
||
9 | use Cycle\ORM\Transaction; |
||
10 | use Yiisoft\Yii\Cycle\Data\Reader\EntityReader; |
||
11 | |||
12 | final class PostRepository extends Select\Repository |
||
13 | { |
||
14 | private ORMInterface $orm; |
||
15 | |||
16 | 5 | public function __construct(Select $select, ORMInterface $orm) |
|
17 | { |
||
18 | 5 | $this->orm = $orm; |
|
19 | 5 | parent::__construct($select); |
|
20 | } |
||
21 | |||
22 | 1 | public function findAll(array $scope = [], array $orderBy = []): EntityReader |
|
23 | { |
||
24 | 1 | return new EntityReader( |
|
25 | $this |
||
26 | 1 | ->select() |
|
27 | 1 | ->where($scope) |
|
28 | 1 | ->orderBy($orderBy) |
|
29 | ); |
||
30 | } |
||
31 | |||
32 | 2 | public function save(Post $user): void |
|
33 | { |
||
34 | 2 | $transaction = new Transaction($this->orm); |
|
0 ignored issues
–
show
Deprecated Code
introduced
by
![]() |
|||
35 | 2 | $transaction->persist($user); |
|
36 | 2 | $transaction->run(); |
|
37 | } |
||
38 | } |
||
39 |