public function testAddCustomListener() { \UsersLogin::login('root', self::PASSWORD); \EventController::addRuntimeEventListener(Search::EventName, function ($request) { $result = new SearchResultModel(); $result->title = 'world!'; $results = [$result]; return $results; }); $api = new Search(['request' => 'hello?']); $response = $api->exec(); $this->assertEquals('world!', $response['items'][0]->title->getValue()); }
// SITEMAP constants define('SITEMAP_TABLE', 'sitemap'); define('SITEMAP_SCRIPT_CHILD_TABLE', 'sitemap_scripts_child'); define('SITEMAP_HISTORY_TABLE', 'sitemap_history'); // Custom Config define('CCONFIG', 'cconfig'); define('CCONFIG_SCHEMA_TABLE', 'custom_config_schema'); define('CCONFIG_TABSHEETS_TABLE', 'custom_config_groups'); define('CCONFIG_CONTROL_TABLE', 'custom_config_items'); define('CCONFIG_CONTROLS_PATH', LIB_PATH . 'custom_config/controls/'); // define('USERS', 'users'); define('USERS_TABLE', 'users'); // Core packages require_once LIB_PATH . 'kernel/extasy.php'; // Trace::start(); // Configure::write('Schedule.AutoloadScriptPath', APPLICATION_PATH . 'scheduleRestart.php'); Configure::write('Exception.Handler', array('\\Extasy\\errors\\Handlers', 'onException')); Configure::write('Error.Handler', array('\\Extasy\\errors\\Handlers', 'onError')); Configure::write('FatalError.Handler', array('\\Extasy\\errors\\Handlers', 'onFatalError')); require_once LIB_PATH . 'ClassLocator.php'; require_once LIB_PATH . 'Autoloader.php'; \Extasy\Autoloader::startup(); Debug::enable(); \EventController::addRuntimeEventListener(\Extasy\Api\ApiOperation::EventName, function () { \Extasy\Audit\Api\ApiOperation::startUp(); \Extasy\Users\UsersModule::initAPI(); }); }
protected function initializeApis() { \EventController::addRuntimeEventListener(\Extasy\Api\ApiOperation::EventName, function () { $controller = \Extasy\Api\ApiController::getInstance(); $controller->add(new \Extasy\Schedule\Api\Add()); $controller->add(new \Extasy\Schedule\Api\Cancel()); $controller->add(new \Extasy\Schedule\Api\Latests()); $controller->add(new \Extasy\Schedule\Api\Restart()); $controller->add(new \Extasy\Schedule\Api\RestartServer()); $controller->add(new \Extasy\Schedule\Api\ServerStatus()); $controller->add(new \Extasy\Schedule\Api\StopServer()); $controller->add(new Search()); }); }