-
Notifications
You must be signed in to change notification settings - Fork 5
/
dic.module
61 lines (54 loc) · 1.2 KB
/
dic.module
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
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* @file
* This file contains all the dic hook implementations.
*/
// Also require the autoloader if drush is being used.
if (drupal_is_cli()) {
dic_boot();
}
/**
* Implements hook_boot().
*/
function dic_boot() {
static $registered = FALSE;
if (!$registered) {
$autoloader = DRUPAL_ROOT . '/vendor/autoload.php';
if (file_exists($autoloader)) {
$registered = TRUE;
require $autoloader;
}
}
}
/**
* Implements hook_admin_menu_cache_info().
*/
function dic_admin_menu_cache_info() {
$caches['dic'] = array(
'title' => t('Dependency Injection Container'),
'callback' => 'dic_clear_container_cache',
);
return $caches;
}
/**
* Implements hook_modules_enabled().
*/
function dic_modules_enabled($modules) {
dic_clear_container_cache();
}
/**
* Implements hook_modules_disabled().
*/
function dic_modules_disabled($modules) {
dic_clear_container_cache();
}
/**
* Clear the Dependency Injection Container.
*/
function dic_clear_container_cache() {
$container_path = drupal_realpath('public://') . '/.container/container.php';
if (file_exists($container_path)) {
unlink($container_path);
}
cache_clear_all('dic_service_paths', 'cache_bootstrap');
}