-
Notifications
You must be signed in to change notification settings - Fork 1
/
classloader_composer.module
executable file
·70 lines (59 loc) · 1.57 KB
/
classloader_composer.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
62
63
64
65
66
67
68
69
70
<?php
/**
* Implementation of @see hook_menu()
*/
function classloader_composer_menu() {
$items = array();
$items['admin/config/development/classloader_composer'] = array(
'title' => 'Composer Autoload settings',
'description' => "Configure Composer Autoload settings.",
'page callback' => 'drupal_get_form',
'page arguments' => array('classloader_composer_admin_settings_form'),
'access arguments' => array('administer classloader'),
'weight' => 10,
'file' => 'classloader_composer.admin.inc',
);
return $items;
}
/**
* Retrieves the classloader
*/
function drupal_classloader() {
static $loader;
if (!$loader) {
$autoload_file = variable_get('composer_vendor_dir', DRUPAL_ROOT . '/../vendor') . '/autoload.php';
if (file_exists($autoload_file)) {
$loader = require $autoload_file;
if (extension_loaded('apc') && variable_get('composer_use_apc', false)) {
$cachedLoader = new \Symfony\Component\ClassLoader\ApcClassLoader('drupal', $loader);
$cachedLoader->register();
$loader->unregister();
}
}
}
return $loader;
}
/**
* Implements hook_boot().
*/
function classloader_composer_boot() {
drupal_classloader();
}
/**
* Implements hook_init().
*/
function classloader_composer_init() {
drupal_classloader();
}
/**
* Implements hook_modules_installed().
*/
function classloader_composer_modules_installed(array $modules) {
drupal_classloader();
}
/**
* Implements hook_modules_enabled().
*/
function classloader_composer_modules_enabled(array $modules) {
drupal_classloader();
}