-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathModuleCodeFile.php
More file actions
50 lines (43 loc) · 1.18 KB
/
ModuleCodeFile.php
File metadata and controls
50 lines (43 loc) · 1.18 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
<?php
namespace DrupalCodeBuilder\Generator;
/**
* Generator class for module code files.
*/
class ModuleCodeFile extends PHPFile {
/**
* {@inheritdoc}
*/
public function getMergeTag() {
return $this->component_data['filename'];
}
/**
* Build the code files.
*/
public function getFileInfo() {
// Create a build list tag from the filename.
$filename_pieces = explode('.', $this->component_data['filename']);
if ($filename_pieces[0] == '%module') {
// Take off the module name from the front.
array_shift($filename_pieces);
}
if (in_array(end($filename_pieces), ['php', 'inc'])) {
// Take off a file extenstion.
array_pop($filename_pieces);
}
// Implode whatever's left.
$file_key_tag = implode('.', $filename_pieces);
return array(
'path' => '', // Means base folder.
'filename' => $this->component_data['filename'],
'body' => $this->fileContents(),
'build_list_tags' => ['code', $file_key_tag],
);
}
/**
* Return a file footer.
*/
function code_footer() {
$footer = \DrupalCodeBuilder\Factory::getEnvironment()->getSetting('footer', '');
return $footer;
}
}