Permalink
Browse files

Added the magic parameter jsonp_callback that when invoked in in the …

…JS outputHandler returns the jsonp function instead of the traditional (function(){});
  • Loading branch information...
1 parent adcd590 commit da8e561907363960bcdbb8dd17cb9bd2958d2e28 David Coallier committed Aug 30, 2011
Showing with 16 additions and 0 deletions.
  1. +16 −0 src/frapi/library/Frapi/Controller/Api.php
@@ -134,6 +134,22 @@ public function processOutput()
);
}
+
+ /**
+ * Here we look for the temporary params so we can
+ * automatically replace the jsonp_callback and handle
+ * it in the OutputHandlers transparently.
+ */
+ $tmpParams = $this->actionContext->getParams();
+ if (isset($tmpParams['jsonp_callback'])) {
+ $response->setData(
+ $response->getData() +
+ array('jsonp_callback' => $tmpParams['jsonp_callback'])
+ );
+ }
+
+ unset($tmpParams);
+
/**
* If the action result is NOT an instance of
* Error, we can assume that it's valid

0 comments on commit da8e561

Please sign in to comment.