1 | <?php |
||
21 | class Factory |
||
22 | { |
||
23 | /** |
||
24 | * Collection name. |
||
25 | */ |
||
26 | public const COLLECTION_NAME = 'namespaces'; |
||
27 | |||
28 | /** |
||
29 | * Database. |
||
30 | * |
||
31 | * @var Database |
||
32 | */ |
||
33 | protected $db; |
||
34 | |||
35 | /** |
||
36 | * Resource factory. |
||
37 | * |
||
38 | * @var ResourceFactory |
||
39 | */ |
||
40 | protected $resource_factory; |
||
41 | |||
42 | /** |
||
43 | * Datatype. |
||
44 | * |
||
45 | * @var CollectionFactory |
||
46 | */ |
||
47 | protected $collection_factory; |
||
48 | |||
49 | /** |
||
50 | * Initialize. |
||
51 | */ |
||
52 | 11 | public function __construct(Database $db, CollectionFactory $collection_factory, ResourceFactory $resource_factory) |
|
58 | |||
59 | /** |
||
60 | * Has namespace. |
||
61 | */ |
||
62 | 9 | public function has(string $name): bool |
|
66 | |||
67 | /** |
||
68 | * Get all. |
||
69 | */ |
||
70 | 3 | public function getAll(?array $query = null, ?int $offset = null, ?int $limit = null, ?array $sort = null): Generator |
|
78 | |||
79 | /** |
||
80 | * Get namespace. |
||
81 | */ |
||
82 | 4 | public function getOne(string $name): ResourceNamespaceInterface |
|
96 | |||
97 | /** |
||
98 | * Update. |
||
99 | */ |
||
100 | public function update(ResourceNamespaceInterface $resource, array $data): bool |
||
108 | |||
109 | /** |
||
110 | * Delete by name. |
||
111 | */ |
||
112 | 2 | public function deleteOne(string $name): bool |
|
118 | |||
119 | /** |
||
120 | * Add namespace. |
||
121 | */ |
||
122 | 8 | public function add(array $resource): ObjectIdInterface |
|
133 | |||
134 | /** |
||
135 | * Change stream. |
||
136 | */ |
||
137 | public function watch(?ObjectIdInterface $after = null, bool $existing = true, ?array $query = null, ?int $offset = null, ?int $limit = null, ?array $sort = null): Generator |
||
145 | |||
146 | /** |
||
147 | * Build instance. |
||
148 | */ |
||
149 | 5 | public function build(array $resource): ResourceNamespaceInterface |
|
153 | } |
||
154 |