1 | <?php |
||
26 | class RelationFactory implements RelationFactoryInterface |
||
27 | { |
||
28 | const RELATION_ONE = 'one'; |
||
29 | const RELATION_MANY = 'many'; |
||
30 | const RELATION_ONE_TROUGH = 'oneTrough'; |
||
31 | const RELATION_MANY_TROUGH = 'manyTrough'; |
||
32 | |||
33 | /** |
||
34 | * @var StorageInterface |
||
35 | */ |
||
36 | protected $storage; |
||
37 | |||
38 | /** |
||
39 | * @var ModelBag |
||
40 | */ |
||
41 | protected $bag; |
||
42 | |||
43 | /** |
||
44 | * Constructor |
||
45 | * |
||
46 | * @param StorageInterface $storage |
||
47 | * @param ModelBag $models |
||
48 | */ |
||
49 | public function __construct(StorageInterface $storage, ModelBag $models) |
||
54 | |||
55 | /** |
||
56 | * Sets model and its relation |
||
57 | * |
||
58 | * @param ModelInterface $model |
||
59 | * @param string $relation |
||
60 | * |
||
61 | * @return RelationInterface |
||
62 | * @throws RelationException |
||
63 | */ |
||
64 | public function build(ModelInterface $model, $relation) |
||
92 | |||
93 | /** |
||
94 | * Fetches relation |
||
95 | * |
||
96 | * @param ModelInterface $model |
||
97 | * @param string $relation |
||
98 | * |
||
99 | * @return RelationDefinitionInterface |
||
100 | * @throws QueryException |
||
101 | */ |
||
102 | protected function fetchDefinition(ModelInterface $model, $relation) |
||
110 | |||
111 | /** |
||
112 | * Splits relation name |
||
113 | * |
||
114 | * @param string $relationName |
||
115 | * |
||
116 | * @return array |
||
117 | */ |
||
118 | public function splitRelationName($relationName) |
||
126 | } |
||
127 |