-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathGeneratedExtension.php
More file actions
50 lines (40 loc) · 1.18 KB
/
GeneratedExtension.php
File metadata and controls
50 lines (40 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\File;
/**
* Represents a generated extension.
*
* This is a bit of a hack added on for FixtureGenerationDrushCommands.
* However, it might ultimately replace the array of CodeFile objects returned
* by Generate.
*/
class GeneratedExtension extends DrupalExtension {
/**
* Constructs a new extension.
*
* @param string $extension_type
* The type.
* @param string $name
* The extension machine name.
* @param array $extension_files
* The generated extension files.
*/
public function __construct(string $extension_type, string $name, array $extension_files) {
$this->type = $extension_type;
$this->name = $name;
$this->files = $extension_files;
}
/**
* {@inheritdoc}
*/
public function hasFile(string $relative_file_path): bool {
$relative_file_path = str_replace('%module', $this->name, $relative_file_path);
return isset($this->files[$relative_file_path]);
}
/**
* {@inheritdoc}
*/
protected function getFileContents($relative_file_path) {
$relative_file_path = str_replace('%module', $this->name, $relative_file_path);
return $this->files[$relative_file_path];
}
}