mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-13 23:28:39 +00:00
Implement file import
This commit is contained in:
parent
d4bc7a66bf
commit
c126670789
|
|
@ -69,6 +69,35 @@ final class EventManager
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add events from file.
|
||||||
|
*
|
||||||
|
* @param string $path Hook file path
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function importFromFile(string $path) : bool
|
||||||
|
{
|
||||||
|
if (!\file_exists($path)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @noinspection PhpIncludeInspection */
|
||||||
|
$hooks = include $path;
|
||||||
|
|
||||||
|
foreach ($hooks as $group => $hook) {
|
||||||
|
foreach ($hook['callback'] as $callbacks) {
|
||||||
|
foreach ($callbacks as $callback) {
|
||||||
|
$this->attach($group, $callback, $hook['remove'] ?? false, $hook['reset'] ?? true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attach new event
|
* Attach new event
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user