-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
28 lines (22 loc) · 1.01 KB
/
Copy pathbootstrap.php
File metadata and controls
28 lines (22 loc) · 1.01 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
<?php
// Load configuration from APP/config/Bakeoff/Checkpoint.php
\Cake\Core\Configure::load($this->getName(), 'default');
// Ensure we get plugin name in PHP namespace format, i.e. with backslashes
$pluginNamespace = str_replace('/', '\\', $this->getName());
// Get configured adapter, either just name, or in full and with namespace
$adapter = \Cake\Core\Configure::read($this->getName().'.adapter');
// Default to built-in example adapter
if (empty($adapter)) {
$adapter = 'Honeypot';
}
// Ensure full adapter class path including namespace
if (strpos($adapter, '\\') === false) {
$adapter = $pluginNamespace . '\\Controller\\Adapter\\' . $adapter . 'Controller';
}
// Alias virtual ChallengeController to currently configured adapter
if (\class_exists($adapter)) {
$controllerPath = sprintf('%s\Controller\ChallengeController', $pluginNamespace);
\class_alias($adapter, $controllerPath);
} else {
throw new \Cake\Http\Exception\InternalErrorException(sprintf("Adapter '%s' does not exist", $adapter));
}