This repository was archived by the owner on Jul 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenable_twig_debugging.install
More file actions
40 lines (35 loc) · 1.48 KB
/
Copy pathenable_twig_debugging.install
File metadata and controls
40 lines (35 loc) · 1.48 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
<?php
/**
* @file
* Enable Twig Debugging.
*/
/**
* Implements hook_install().
*/
function enable_twig_debugging_install(): void {
$source = DRUPAL_ROOT . '/sites/default/default.services.yml';
$site_path = \Drupal::service('site.path');
$destination = DRUPAL_ROOT . '/' . $site_path . '/services.yml';
chmod(DRUPAL_ROOT . '/' . $site_path, 0777);
touch($destination);
copy($source, $destination);
chmod(DRUPAL_ROOT . '/' . $site_path, 0555);
file_put_contents($destination, str_replace('debug: false', 'debug: true', file_get_contents($destination)));
file_put_contents($destination, str_replace('auto_reload: null', 'auto_reload: false', file_get_contents($destination)));
file_put_contents($destination, str_replace('cache: true', 'cache: false', file_get_contents($destination)));
drupal_flush_all_caches();
}
/**
* Implements hook_uninstall().
*/
function enable_twig_debugging_uninstall(): void {
$site_path = \Drupal::service('site.path');
$source = DRUPAL_ROOT . '/' . $site_path . '/' . 'services.yml';
chmod(DRUPAL_ROOT . '/' . $site_path, 0777);
file_put_contents($source, str_replace('debug: true', 'debug: false', file_get_contents($source)));
file_put_contents($source, str_replace('auto_reload: false', 'auto_reload: null', file_get_contents($source)));
file_put_contents($source, str_replace('cache: false', 'cache: true', file_get_contents($source)));
unlink($source);
chmod(DRUPAL_ROOT . '/' . $site_path, 0555);
drupal_flush_all_caches();
}