-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
ManagerInterface.php
93 lines (82 loc) · 2.16 KB
/
ManagerInterface.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
declare(strict_types=1);
/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sonata\Doctrine\Model;
/**
* @author Sylvain Deloux <[email protected]>
*
* @phpstan-template T of object
*/
interface ManagerInterface
{
/**
* Return the Entity class name.
*
* @phpstan-return class-string<T>
*/
public function getClass(): string;
/**
* Find all entities in the repository.
*
* @return object[]
*
* @phpstan-return T[]
*/
public function findAll(): array;
/**
* Find entities by a set of criteria.
*
* @param array<string, mixed> $criteria
* @param array<string, 'asc'|'ASC'|'desc'|'DESC'>|null $orderBy
*
* @return object[]
*
* @phpstan-return T[]
*/
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array;
/**
* Find a single entity by a set of criteria.
*
* @param array<string, mixed> $criteria
*
* @phpstan-return T|null
*/
public function findOneBy(array $criteria): ?object;
/**
* Finds an entity by its primary key / identifier.
*
* @phpstan-return T|null
*/
public function find(mixed $id): ?object;
/**
* Create an empty Entity instance.
*
* @phpstan-return T
*/
public function create(): object;
/**
* Save an Entity.
*
* @param object $entity The Entity to save
* @param bool $andFlush Flush the EntityManager after saving the object?
*
* @phpstan-param T $entity
*/
public function save(object $entity, bool $andFlush = true): void;
/**
* Delete an Entity.
*
* @param object $entity The Entity to delete
* @param bool $andFlush Flush the EntityManager after deleting the object?
*
* @phpstan-param T $entity
*/
public function delete(object $entity, bool $andFlush = true): void;
}