/** * @param string $type */ public function runHandlers(StoryTeller $st, $type) { // shorthand $output = $st->getOutput(); // Do we have any persistent tables to cleanup? $runtimeConfig = $st->getRuntimeConfig(); if (!isset($runtimeConfig->storyplayer, $runtimeConfig->storyplayer->tables)) { // there are no tables at all return; } // if we get here, then we know that there are persistent // tables that we need to cleanup // this will keep track of any tables that have no associated // cleanup handler $missingCleanupHandlers = []; // Take a look at all of our process list tables foreach ($runtimeConfig->storyplayer->tables as $key => $value) { $className = "cleanup" . ucfirst($key); try { $st->{$className}($key)->{$type}(); } catch (E5xx_NoMatchingActions $e) { // We don't know about a cleanup module for this, SHOUT LOUDLY $missingCleanupHandlers[] = "Missing cleanup module for '{$key}'" . PHP_EOL; } } // Now we've cleaned everything up, save the runtime config $st->saveRuntimeConfig(); // If we have any missing cleanup handlers, output it to the screen // and exit with an error code if (count($missingCleanupHandlers)) { foreach ($missingCleanupHandlers as $msg) { $output->logCliError($msg); } exit(1); } }