1 | <?php |
||
11 | class ModelFactory extends Component |
||
12 | { |
||
13 | use Filesystem; |
||
14 | |||
15 | /** |
||
16 | * Faker instance. |
||
17 | * |
||
18 | * @var Generator |
||
19 | */ |
||
20 | protected $faker; |
||
21 | |||
22 | /** |
||
23 | * Array of user defined factory definitions. |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $definitions; |
||
28 | |||
29 | /** |
||
30 | * Construct. |
||
31 | * |
||
32 | * @param Generator $faker |
||
33 | */ |
||
34 | public function __construct(Generator $faker) |
||
40 | |||
41 | /** |
||
42 | * Make instances of class, overriding default values with attributes. |
||
43 | * |
||
44 | * @param string $class |
||
45 | * @param array $attributes |
||
46 | * @param int $times |
||
47 | * |
||
48 | * @return Phalcon\Mvc\Model|array |
||
49 | */ |
||
50 | public function make($class, array $attributes = [], $times = null) |
||
54 | |||
55 | /** |
||
56 | * Make instances of class using name. |
||
57 | * |
||
58 | * @param string $class |
||
59 | * @param string $name |
||
60 | * @param array $attributes |
||
61 | * @param int $times |
||
62 | * |
||
63 | * @return Phalcon\Mvc\Model|array |
||
64 | */ |
||
65 | public function makeAs($class, $name, array $attributes = [], $times = null) |
||
69 | |||
70 | /** |
||
71 | * Create instances of class, overriding default values with attributes. |
||
72 | * |
||
73 | * @param string $class |
||
74 | * @param array $attributes |
||
75 | * @param int $times |
||
76 | * |
||
77 | * @return Phalcon\Mvc\Model|array |
||
78 | */ |
||
79 | public function create($class, array $attributes = [], $times = null) |
||
83 | |||
84 | /** |
||
85 | * Create instances of class using name. |
||
86 | * |
||
87 | * @param string $class |
||
88 | * @param string $name |
||
89 | * @param array $attributes |
||
90 | * @param int $times |
||
91 | * |
||
92 | * @return Phalcon\Mvc\Model|array |
||
93 | */ |
||
94 | public function createAs($class, $name, array $attributes = [], $times = null) |
||
98 | |||
99 | /** |
||
100 | * Get instance of factory builder with set attributes. |
||
101 | * |
||
102 | * @param string $class |
||
103 | * @param string $name |
||
104 | * |
||
105 | * @return ModelFactoryBuilder |
||
106 | */ |
||
107 | public function forClass($class, $name = 'default') |
||
116 | |||
117 | /** |
||
118 | * Load factory definitions onto object. |
||
119 | * |
||
120 | * @return $this |
||
121 | */ |
||
122 | protected function load() |
||
139 | |||
140 | /** |
||
141 | * Require all factory files in path. |
||
142 | * |
||
143 | * @param string $path |
||
144 | * @param ModelFactory $factory |
||
145 | * |
||
146 | * @throws FactoryNotFound |
||
147 | */ |
||
148 | protected function requireFactories($path, $factory) |
||
164 | |||
165 | /** |
||
166 | * Define a class with a given set of attributes. |
||
167 | * |
||
168 | * @param string $class |
||
169 | * @param callable $attributes |
||
170 | * @param string $name |
||
171 | * |
||
172 | * @return $this |
||
173 | */ |
||
174 | public function define($class, callable $attributes, $name = 'default') |
||
180 | } |
||
181 |