-
-
Notifications
You must be signed in to change notification settings - Fork 547
Expand file tree
/
Copy pathDrupal.php
More file actions
80 lines (65 loc) · 2 KB
/
Drupal.php
File metadata and controls
80 lines (65 loc) · 2 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
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
71
72
73
74
75
76
77
78
79
80
<?php
namespace Drupal\Console\Bootstrap;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Symfony\Component\HttpFoundation\Request;
class Drupal
{
protected $autoload;
protected $root;
protected $appRoot;
/**
* Drupal constructor.
* @param $autoload
* @param $root
*/
public function __construct($autoload, $root, $appRoot)
{
$this->autoload = $autoload;
$this->root = $root;
$this->appRoot = $appRoot;
}
public function boot()
{
$request = Request::createFromGlobals();
try {
$drupalKernel = DrupalKernel::createFromRequest(
$request,
$this->autoload,
'prod',
false
);
} catch (\Exception $e) {
$drupal = new DrupalConsoleCore($this->root, $this->appRoot);
return $drupal->boot();
}
$drupalKernel->addServiceModifier(
new DrupalServiceModifier(
$this->root,
'drupal.command',
'drupal.generator'
)
);
$drupalKernel->invalidateContainer();
$drupalKernel->rebuildContainer();
$drupalKernel->boot();
$container = $drupalKernel->getContainer();
$container->set('console.root', $this->root);
AnnotationRegistry::registerLoader([$this->autoload, "loadClass"]);
$configuration = $container->get('console.configuration_manager')
->loadConfiguration($this->root)
->getConfiguration();
$container->get('console.translator_manager')
->loadCoreLanguage(
$configuration->get('application.language'),
$this->root
);
$container->get('console.renderer')
->setSkeletonDirs(
[
DRUPAL_CONSOLE.'/templates/',
DRUPAL_CONSOLE_CORE.'/templates/'
]
);
return $container;
}
}