mirror of
https://github.com/e107inc/e107.git
synced 2025-08-08 23:56:58 +02:00
Preparation for merge with e107 repository
Moved all test files to e107_tests subdirectory
This commit is contained in:
46
e107_tests/lib/PriorityCallbacks.php
Normal file
46
e107_tests/lib/PriorityCallbacks.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Execute callbacks before Codeception does
|
||||
*/
|
||||
|
||||
class PriorityCallbacks
|
||||
{
|
||||
/** @var array */
|
||||
private $shutdown_functions = [];
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
register_shutdown_function([$this, 'call_shutdown_functions']);
|
||||
}
|
||||
|
||||
public static function instance()
|
||||
{
|
||||
static $instance = null;
|
||||
if (!$instance instanceof self)
|
||||
{
|
||||
$instance = new static();
|
||||
}
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function call_shutdown_functions()
|
||||
{
|
||||
foreach ($this->shutdown_functions as $shutdown_function)
|
||||
{
|
||||
call_user_func($shutdown_function);
|
||||
}
|
||||
}
|
||||
|
||||
public function register_shutdown_function($callable)
|
||||
{
|
||||
$this->shutdown_functions[] = $callable;
|
||||
}
|
||||
|
||||
private function __clone() {}
|
||||
|
||||
private function __sleep() {}
|
||||
|
||||
private function __wakeup() {}
|
||||
}
|
||||
|
||||
PriorityCallbacks::instance();
|
Reference in New Issue
Block a user