Regenerate sql/civicrm_generated.mysql
[civicrm-core.git] / setup / plugins / installFiles / CreateTemplateCompilePath.civi-setup.php
CommitLineData
4bcd4c62
TO
1<?php
2/**
3 * @file
4 *
5 * Validate and create the template compile folder.
6 */
7
8if (!defined('CIVI_SETUP')) {
9 exit("Installation plugins must only be loaded by the installer.\n");
10}
11
12\Civi\Setup::dispatcher()
13 ->addListener('civi.setup.checkRequirements', function (\Civi\Setup\Event\CheckRequirementsEvent $e) {
14 \Civi\Setup::log()->info(sprintf('[%s] Handle %s', basename(__FILE__), 'checkRequirements'));
15 $m = $e->getModel();
16
17 if (empty($m->templateCompilePath)) {
18 $e->addError('system', 'templateCompilePath', sprintf('The templateCompilePath is undefined.'));
19 }
20 else {
21 $e->addInfo('system', 'templateCompilePath', 'The templateCompilePath is defined.');
22 }
23
24 if (!\Civi\Setup\FileUtil::isCreateable($m->templateCompilePath)) {
25 $e->addError('system', 'templateCompilePathWritable', sprintf('The template compile dir "%s" cannot be created. Ensure the parent folder is writable.', $m->templateCompilePath));
26 }
27 else {
28 $e->addInfo('system', 'templateCompilePathWritable', sprintf('The template compile dir "%s" can be created.', $m->templateCompilePath));
29 }
30 });
31
32\Civi\Setup::dispatcher()
33 ->addListener('civi.setup.installFiles', function (\Civi\Setup\Event\InstallFilesEvent $e) {
34 \Civi\Setup::log()->info(sprintf('[%s] Handle %s', basename(__FILE__), 'installFiles'));
35 $m = $e->getModel();
36
37 if (!file_exists($m->templateCompilePath)) {
38 Civi\Setup::log()->info('[CreateTemplateCompilePath.civi-setup.php] mkdir "{path}"', [
39 'path' => $m->templateCompilePath,
40 ]);
41 mkdir($m->templateCompilePath, 0777, TRUE);
42 \Civi\Setup\FileUtil::makeWebWriteable($m->templateCompilePath);
43 }
44 });