-
-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathFactoryInterface.php
More file actions
109 lines (96 loc) · 3.01 KB
/
FactoryInterface.php
File metadata and controls
109 lines (96 loc) · 3.01 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
declare(strict_types=1);
namespace Cycle\ORM;
use Cycle\Database\DatabaseInterface;
use Cycle\Database\DatabaseProviderInterface;
use Cycle\ORM\Collection\CollectionFactoryInterface;
use Cycle\ORM\Parser\TypecastInterface;
use Cycle\ORM\Service\SourceProviderInterface;
use Cycle\ORM\Relation\RelationInterface;
use Cycle\ORM\Select\LoaderInterface;
use Cycle\ORM\Select\SourceInterface;
use Spiral\Core\FactoryInterface as CoreFactory;
/**
* Must provide access to generic DI.
*/
interface FactoryInterface extends DatabaseProviderInterface, CoreFactory
{
public const PARENT_LOADER = '::parent::';
public const CHILD_LOADER = '::child::';
/**
* Create mapper associated with given role.
*/
public function mapper(
ORMInterface $orm,
string $role,
): MapperInterface;
/**
* Create loader associated with specific entity and relation.
*/
public function loader(
SchemaInterface $schema,
SourceProviderInterface $sourceProvider,
string $role,
string $relation,
): LoaderInterface;
/**
* @template TEntity of object
*
* Create repository associated with given role.
*
* @param non-empty-string|class-string<TEntity> $role
* @return ($role is class-string<TEntity> ? RepositoryInterface<TEntity> : RepositoryInterface<object>)
*/
public function repository(
ORMInterface $orm,
SchemaInterface $schema,
string $role,
?Select $select,
): RepositoryInterface;
/**
* Create typecast implementation associated with given role.
*/
public function typecast(
SchemaInterface $schema,
DatabaseInterface $database,
string $role,
): ?TypecastInterface;
/**
* Create source associated with given role.
*/
public function source(
SchemaInterface $schema,
string $role,
): SourceInterface;
/**
* @param class-string|string|null $name Collection factory name.
* Can be class name or alias that can be configured in the {@see withCollectionFactory()} method.
*/
public function collection(
?string $name = null,
): CollectionFactoryInterface;
/**
* Create relation associated with specific entity and relation.
*/
public function relation(
ORMInterface $orm,
SchemaInterface $schema,
string $role,
string $relation,
): RelationInterface;
/**
* Add default classes for producing
*/
public function withDefaultSchemaClasses(array $defaults): self;
/**
* Configure additional collection factories.
*
* @param string $alias Collection alias name that can be used in {@see Relation::COLLECTION_TYPE} parameter.
* @param class-string|null $interface An interface or base class that is common to the collections produced.
*/
public function withCollectionFactory(
string $alias,
CollectionFactoryInterface $factory,
?string $interface = null,
): self;
}