Total Complexity | 6 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class InterfaceGenerator extends BaseGenerator |
||
10 | { |
||
11 | /** @var CommandData */ |
||
12 | private $commandData; |
||
13 | |||
14 | /** @var string */ |
||
15 | private $path; |
||
16 | |||
17 | /** @var string */ |
||
18 | private $fileName; |
||
19 | |||
20 | public function __construct(CommandData $commandData) |
||
21 | { |
||
22 | $this->commandData = $commandData; |
||
23 | $this->path = $commandData->config->pathInterface; |
||
24 | $this->fileName = $this->commandData->modelName.'RepositoryInterface.php'; |
||
25 | } |
||
26 | |||
27 | public function generate() |
||
28 | { |
||
29 | $templateData = get_artomator_template('interface'); |
||
30 | |||
31 | $templateData = fill_template($this->commandData->dynamicVars, $templateData); |
||
32 | |||
33 | $searchables = []; |
||
34 | |||
35 | foreach ($this->commandData->fields as $field) { |
||
36 | if ($field->isSearchable) { |
||
37 | $searchables[] = "'".$field->name."'"; |
||
38 | } |
||
39 | } |
||
40 | |||
41 | $templateData = str_replace('$FIELDS$', implode(','.infy_nl_tab(1, 2), $searchables), $templateData); |
||
42 | |||
43 | FileUtil::createFile($this->path, $this->fileName, $templateData); |
||
44 | |||
45 | $this->commandData->commandComment("\nRepository Interface created: "); |
||
46 | $this->commandData->commandInfo($this->fileName); |
||
47 | } |
||
48 | |||
49 | public function rollback() |
||
53 | } |
||
54 | } |
||
55 | } |
||
56 |