-
Notifications
You must be signed in to change notification settings - Fork 3
/
.cradle.php
57 lines (49 loc) · 1.35 KB
/
.cradle.php
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
<?php //-->
/**
* This file is part of a package designed for the CradlePHP Project.
*
* Copyright and license information can be found at LICENSE.txt
* distributed with this package.
*/
require_once __DIR__ . '/package/events.php';
require_once __DIR__ . '/package/helpers.php';
require_once __DIR__ . '/src/events.php';
require_once __DIR__ . '/src/controller.php';
//bootstrap
$this
->preprocess(include __DIR__ . '/src/bootstrap/errors.php')
->preprocess(include __DIR__ . '/src/bootstrap/permitted.php')
->preprocess(include __DIR__ . '/src/bootstrap/session.php');
//lister for role create/update
$this->addLogger(function(
$message,
$request = null,
$response = null,
$type = null,
$table = null,
$id = null
) {
//ignore cli
if (php_sapi_name() === 'cli') {
return;
}
//not role?
if ($table !== 'role') {
return;
}
//if not create or update
if ($type !== 'create' && $type !== 'update') {
return;
}
//get current session
$session = $request->getSession('role');
//skip if current role is not updated
if ($session['role_id'] !== $id) {
return;
}
//get results
$results = $response->getResults();
$session['role_admin_menu'] = $results['role_admin_menu'];
//update session
$request->setSession('role', $session);
});