| 1 | <?php |
| 2 | namespace Civi\Setup; |
| 3 | |
| 4 | class BasicRunner { |
| 5 | |
| 6 | /** |
| 7 | * Execute the controller and display the output. |
| 8 | * |
| 9 | * Note: This is really just an example which handles input and output using |
| 10 | * stock PHP variables and functions. Depending on the environment, |
| 11 | * it may be easier to work directly with `getCtrl()->run(...)` which |
| 12 | * handles inputs/outputs in a more abstract fashion. |
| 13 | * |
| 14 | * @param object $ctrl |
| 15 | * A web controller. |
| 16 | */ |
| 17 | public static function run($ctrl) { |
| 18 | $method = $_SERVER['REQUEST_METHOD']; |
| 19 | list ($headers, $body) = $ctrl->run($method, ($method === 'GET' ? $_GET : $_POST)); |
| 20 | foreach ($headers as $k => $v) { |
| 21 | header("$k: $v"); |
| 22 | } |
| 23 | echo $body; |
| 24 | } |
| 25 | |
| 26 | } |