Last active
December 17, 2015 06:29
-
-
Save joshuaadickerson/5566246 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function viewExit(array $context, $status_code = 200, $template = false) | |
{ | |
call_integration_hook('integrate_pre_view_exit', array(&$context, &$status_code, &$template)); | |
switch ($GLOBALS['output_strategy']) | |
{ | |
case 'json': | |
$content_type = 'text/json'; | |
$output = empty($template) ? json_encode($context) : loadJSONTemplate($template, $context); | |
break; | |
case 'xml': | |
$content_type = 'text/xml'; | |
// This obviously requires another function to create a XML map | |
$output = empty($template) ? xml_encode($context) : loadXMLTemplate($template, $context)); | |
break; | |
case 'debug': | |
$content_type = 'text/text'; | |
$output = print_r($context, true); | |
default: | |
$content_type = 'text/text'; | |
$output = 'No view strategy selected'; | |
trigger_error($output); | |
} | |
call_integration_hook('integrate_view_exit', array(&$context, &$status_code, &$template, &$output); | |
header('Content-Type: ' . $content_type . '; charset=UTF-8'); | |
http_status_code((int) $status_code); | |
die($output); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment