Repository navigation
Expand file tree
/
Copy pathcontroller.php
More file actions
77 lines (61 loc) · 1.66 KB
/
Copy pathcontroller.php
File metadata and controls
77 lines (61 loc) · 1.66 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
<?php
namespace Cig\Sage\Controller;
use Brain\Hierarchy\Hierarchy;
use function App\sage;
/**
* Loader
*/
function loader()
{
if (!function_exists('\App\sage')) {
return;
}
// Run WordPress hierarchy class
$hierarchy = new Hierarchy();
// Run Loader class and pass on WordPress hierarchy class
$loader = new Loader($hierarchy);
// Use the Sage DI container
$container = sage();
// Loop over each class
foreach ($loader->getClassesToRun() as $class) {
// Create the class on the DI container
$controller = $container->make($class);
// Set the params required for location
$controller->__setParams();
// Determine template location to expose data
$location = 'sage/template/data-' . $controller->__getTemplateParam() . '/data';
// Pass data to filter
add_filter($location, function ($data) use ($container, $class) {
// Recreate the class so that $post is included
$controller = $container->make($class);
$controller->__setParams();
// Return the data
return $controller
->__setControllerData()
->__setIncomingData($data)
->__getData();
});
}
}
/**
* Debugger
*/
/*function debugger()
{
if (!function_exists('\App\sage')) {
return;
}
sage('blade')->compiler()->directive('debug', function () {
return '<?php (new \Sober\Controller\Debugger(get_defined_vars())); ?>';
});
sage('blade')->compiler()->directive('dump', function ($param) {
return "<?php (new Illuminate\Support\Debug\Dumper)->dump($param); ?>";
});
}*/
/**
* Hooks
*/
if (function_exists('add_action')) {
add_action('init', __NAMESPACE__ . '\loader');
//add_action('init', __NAMESPACE__ . '\debugger');
}