mirror of https://github.com/MISP/MISP
chg: [internal] Use `BetterCakeEventManager` for AppController
parent
2f644a2a33
commit
6c84e7deb9
|
@ -4,6 +4,7 @@ App::uses('Controller', 'Controller');
|
|||
App::uses('File', 'Utility');
|
||||
App::uses('RequestRearrangeTool', 'Tools');
|
||||
App::uses('BlowfishConstantPasswordHasher', 'Controller/Component/Auth');
|
||||
App::uses('BetterCakeEventManager', 'Tools');
|
||||
|
||||
/**
|
||||
* Application Controller
|
||||
|
@ -1443,6 +1444,16 @@ class AppController extends Controller
|
|||
return parent::_getViewObject();
|
||||
}
|
||||
|
||||
public function getEventManager()
|
||||
{
|
||||
if (empty($this->_eventManager)) {
|
||||
$this->_eventManager = new BetterCakeEventManager();
|
||||
$this->_eventManager->attach($this->Components);
|
||||
$this->_eventManager->attach($this);
|
||||
}
|
||||
return $this->_eventManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close session without writing changes to them and return current user.
|
||||
* @return array
|
||||
|
|
|
@ -979,6 +979,8 @@ class ACLComponent extends Component
|
|||
|
||||
private function __findAllFunctions()
|
||||
{
|
||||
$functionsToIgnore = ['beforeFilter', 'afterFilter', 'beforeRender', 'getEventManager'];
|
||||
|
||||
$functionFinder = '/function[\s\n]+(\S+)[\s\n]*\(/';
|
||||
$dir = new Folder(APP . 'Controller');
|
||||
$files = $dir->find('.*\.php');
|
||||
|
@ -989,11 +991,11 @@ class ACLComponent extends Component
|
|||
$controllerName = '*';
|
||||
}
|
||||
$functionArray = array();
|
||||
$fileContents = file_get_contents(APP . 'Controller' . DS . $file);
|
||||
$fileContents = FileAccessTool::readFromFile(APP . 'Controller' . DS . $file);
|
||||
$fileContents = preg_replace('/\/\*[^\*]+?\*\//', '', $fileContents);
|
||||
preg_match_all($functionFinder, $fileContents, $functionArray);
|
||||
foreach ($functionArray[1] as $function) {
|
||||
if ($function[0] !== '_' && $function !== 'beforeFilter' && $function !== 'afterFilter' && $function !== 'beforeRender') {
|
||||
if ($function[0] !== '_' && !in_array($function, $functionsToIgnore, true)) {
|
||||
$results[$controllerName][] = $function;
|
||||
}
|
||||
}
|
||||
|
@ -1014,8 +1016,7 @@ class ACLComponent extends Component
|
|||
$missing = array();
|
||||
foreach ($results as $controller => $functions) {
|
||||
foreach ($functions as $function) {
|
||||
if (!isset(self::ACL_LIST[$controller])
|
||||
|| !in_array($function, array_keys(self::ACL_LIST[$controller]))) {
|
||||
if (!isset(self::ACL_LIST[$controller]) || !in_array($function, array_keys(self::ACL_LIST[$controller]))) {
|
||||
$missing[$controller][] = $function;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue