disable hooks while rebuild

This commit is contained in:
Yuri Kuznetsov
2020-07-23 11:10:57 +03:00
parent 455ef1138f
commit fbbe0e06cf
2 changed files with 36 additions and 1 deletions

View File

@@ -38,7 +38,6 @@ class DataManager
private $cachePath = 'data/cache';
public function __construct(Container $container)
{
$this->container = $container;
@@ -58,6 +57,8 @@ class DataManager
{
$result = $this->clearCache();
$this->disableHooks();
$this->populateConfigParameters();
$result &= $this->rebuildMetadata();
@@ -66,6 +67,8 @@ class DataManager
$this->rebuildScheduledJobs();
$this->enableHooks();
return $result;
}
@@ -228,4 +231,14 @@ class DataManager
$config->save();
}
protected function disableHooks()
{
$this->getContainer()->get('hookManager')->disable();
}
protected function enableHooks()
{
$this->getContainer()->get('hookManager')->enable();
}
}

View File

@@ -49,6 +49,8 @@ class HookManager
private $data;
protected $isDisabled;
private $hookListHash = [];
private $hooks;
@@ -81,6 +83,10 @@ class HookManager
public function process(string $scope, string $hookName, $injection = null, array $options = [], array $hookData = [])
{
if ($this->isDisabled) {
return;
}
if (!isset($this->data)) {
$this->loadHooks();
}
@@ -99,6 +105,22 @@ class HookManager
}
}
/**
* Disable hook processing.
*/
public function disable()
{
$this->isDisabled = true;
}
/**
* Enable hook processing.
*/
public function enable()
{
$this->isDisabled = false;
}
protected function loadHooks()
{
if ($this->config->get('useCache') && file_exists($this->cacheFile)) {