本文整理汇总了PHP中Phalcon\Mvc\Dispatcher::getReturnedValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::getReturnedValue方法的具体用法?PHP Dispatcher::getReturnedValue怎么用?PHP Dispatcher::getReturnedValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Mvc\Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::getReturnedValue方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createMvcFrom
/**
* @param array $config
* @return MvcDispatcher
*/
public static function createMvcFrom(array $config) : MvcDispatcher
{
$dispatcher = new MvcDispatcher();
$dispatcher->setEventsManager(new EventManager());
$dispatcher->setControllerSuffix(null);
$dispatcher->setDefaultNamespace($config['controllerDefaultNamespace']);
$dispatcher->getEventsManager()->attach('dispatch:afterDispatchLoop', function (Event $event, MvcDispatcher $dispatcher) {
if ($dispatcher->getReturnedValue() instanceof \Phalcon\Http\Response) {
$dispatcher->getDI()->setShared('response', $dispatcher->getReturnedValue());
}
});
return $dispatcher;
}
示例2: afterExecuteRoute
public function afterExecuteRoute(Dispatcher $dispatcher)
{
if ($this->_isJsonResponse) {
$data = $dispatcher->getReturnedValue();
$this->response->setJsonContent($data);
$this->response->send();
}
}
示例3: afterExecuteRoute
public function afterExecuteRoute(Dispatcher $dispatcher)
{
sleep(2);
$data = $dispatcher->getReturnedValue();
$responseData = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
$this->response->setContent($responseData);
return $this->response->send();
}
示例4: afterExecuteRoute
public function afterExecuteRoute(Dispatcher $dispatcher)
{
$this->view->disable();
$data = $dispatcher->getReturnedValue();
if (is_array($data)) {
$data = json_encode($data);
}
$this->response->setContentType('application/json', 'UTF-8');
$this->response->setContent($data);
$this->response->send();
}
示例5: afterExecuteRoute
public function afterExecuteRoute(Dispatcher $dispatcher)
{
if ($this->_isJsonResponse) {
$data = $dispatcher->getReturnedValue();
if (is_array($data)) {
$data = json_encode($data);
}
$this->response->setContent($data);
$this->response->send();
}
}
示例6: afterExecuteRoute
public function afterExecuteRoute(Dispatcher $dispatcher)
{
$data = $dispatcher->getReturnedValue();
if ($this->restful) {
if (is_array($data)) {
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
}
}
$this->response->setContent($data);
$this->response->send();
}
示例7: afterExecuteRoute
/**
* After route executed event
*
* @param Dispatcher $dispatcher
*/
public function afterExecuteRoute(Dispatcher $dispatcher)
{
$data = $dispatcher->getReturnedValue();
if (is_array($data)) {
$this->response->setJsonContent($data, JSON_UNESCAPED_UNICODE);
} elseif (is_scalar($data)) {
$this->response->setContent($data);
}
$this->response->send();
exit;
}
示例8: afterExecuteRoute
public function afterExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\Dispatcher $dispatcher)
{
/** @var \Model\ModelsRepository $modelsRepository */
$modelsRepository = $dispatcher->getDI()->getService('modelsRepository')->resolve();
if (!$modelsRepository) {
return;
}
$returnedValue = $dispatcher->getReturnedValue();
if (is_null($returnedValue)) {
$returnedValue = [];
}
$modelsRepository->getPageContent()->processContent($dispatcher->getParams(), $returnedValue);
}
示例9: afterExecuteRoute
public function afterExecuteRoute(Dispatcher $dispatcher)
{
$this->view->disable();
$data = $dispatcher->getReturnedValue();
if (is_array($data) and array_key_exists('success', $data) and $data['success'] === false) {
$this->setBadRequestStatus();
}
if (is_array($data)) {
$data = json_encode($data);
}
$this->response->setContentType('application/json', 'UTF-8');
$this->response->setContent($data);
$this->response->send();
// TODO bug fix
exit;
}
示例10: afterExecuteRoute
public function afterExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\Dispatcher $dispatcher)
{
/** @var \Phalcon\Mvc\View $view */
$view = $dispatcher->getDI()->getService('view')->resolve();
$returnedValue = $dispatcher->getReturnedValue();
if ($returnedValue instanceof \Phalcon\Http\Response) {
return false;
}
if (is_array($view->getParamsToView()) && array_key_exists(self::SET_JSON_RESPONSE, $view->getParamsToView())) {
$view->disable();
header('Content-type: application/json');
echo json_encode($returnedValue);
return false;
}
if (is_array($returnedValue)) {
$view->setVars($returnedValue);
}
}
示例11: afterExecuteRoute
/**
* After execute route event
*
* @param Dispatcher $dispatcher
*/
public function afterExecuteRoute(Dispatcher $dispatcher)
{
if ($this->request->isAjax() && $this->isJsonResponse()) {
$this->view->disable();
$this->response->setContentType('application/json', 'UTF-8');
$data = $dispatcher->getReturnedValue();
if (is_array($data)) {
$this->response->setJsonContent($data);
}
echo $this->response->getContent();
}
$this->view->setViewsDir($this->view->getViewsDir() . 'admin/');
}
示例12: afterExecuteRoute
public function afterExecuteRoute(\Phalcon\Mvc\Dispatcher $dispatcher)
{
$this->setJsonContent($dispatcher->getReturnedValue());
}
示例13: afterDispatchLoop
public function afterDispatchLoop(Event $event, Dispatcher $dispatcher)
{
$di = $this->getDI();
$response = $di->get('response');
$content = $response->getContent();
if ($content === '' && $dispatcher->getActiveController() instanceof RestControllerInterface) {
$returnedResponse = $dispatcher->getReturnedValue() instanceof ResponseInterface;
if ($returnedResponse === false) {
/** @var \PhalconRest\Mvc\RestView $rest */
$rest = $di->get('rest');
/** @var Manager $eventsManager */
$eventsManager = $this->_eventsManager;
//$eventsManager = $dispatcher->getDI()->get('eventsManager');
$renderStatus = true;
if ($eventsManager instanceof ManagerInterface) {
$renderStatus = $eventsManager->fire('application:viewRender', $this, $rest);
}
if ($renderStatus) {
$rest->render($dispatcher->getControllerName(), $dispatcher->getActionName());
$content = $rest->getContent();
}
/** @var \Phalcon\Http\Response $response */
$response = $di->get('response');
$response->setContent($content)->send();
}
}
}
示例14: afterDispatch
/**
*
* @param Event $event
* @param Dispatcher $dispatcher
*/
public function afterDispatch(Event $event, Dispatcher $dispatcher)
{
$result = $dispatcher->getReturnedValue();
ResponseApi::sendOk($result);
}