1 | <?php |
||
17 | class ModelProvider |
||
18 | { |
||
19 | /** |
||
20 | * @var callable {@link Model} provider |
||
21 | */ |
||
22 | static private $provider; |
||
23 | |||
24 | /** |
||
25 | * Defines the {@link Model} provider. |
||
26 | * |
||
27 | * @param callable $provider |
||
28 | * |
||
29 | * @return callable The previous provider, or `null` if none was defined. |
||
30 | */ |
||
31 | static public function define(callable $provider) |
||
39 | |||
40 | /** |
||
41 | * Returns the current provider. |
||
42 | * |
||
43 | * @return callable|null |
||
44 | */ |
||
45 | static public function defined() |
||
49 | |||
50 | /** |
||
51 | * Undefine the provider. |
||
52 | */ |
||
53 | static public function undefine() |
||
57 | |||
58 | /** |
||
59 | * Returns a {@link Model} instance using the provider. |
||
60 | * |
||
61 | * @param string $id Model identifier. |
||
62 | * |
||
63 | * @return Model |
||
64 | * |
||
65 | * @throws ModelNotDefined if the model cannot be provided. |
||
66 | */ |
||
67 | static public function provide($id) |
||
85 | } |
||
86 |