Commit | Line | Data |
---|---|---|
728bbd5b TO |
1 | <?php |
2 | namespace Civi\Test\CiviEnvBuilder; | |
3 | ||
4 | class SqlFileStep implements StepInterface { | |
5 | private $file; | |
6 | ||
7 | /** | |
8 | * SqlFileStep constructor. | |
9 | * @param string $file | |
10 | */ | |
11 | public function __construct($file) { | |
12 | $this->file = $file; | |
13 | } | |
14 | ||
728bbd5b | 15 | public function getSig() { |
c64f69d9 | 16 | return implode(' ', [ |
728bbd5b TO |
17 | $this->file, |
18 | filemtime($this->file), | |
19 | filectime($this->file), | |
c64f69d9 | 20 | ]); |
728bbd5b TO |
21 | } |
22 | ||
23 | public function isValid() { | |
24 | return is_file($this->file) && is_readable($this->file); | |
25 | } | |
26 | ||
27 | public function run($ctx) { | |
28 | /** @var $ctx \CiviEnvBuilder */ | |
29 | if (\Civi\Test::execute(@file_get_contents($this->file)) === FALSE) { | |
30 | throw new \RuntimeException("Cannot load {$this->file}. Aborting."); | |
31 | } | |
32 | } | |
33 | ||
34 | } |