当前位置: 首页>>代码示例>>PHP>>正文


PHP Controller::render方法代码示例

本文整理汇总了PHP中Cake\Controller\Controller::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::render方法的具体用法?PHP Controller::render怎么用?PHP Controller::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Controller\Controller的用法示例。


在下文中一共展示了Controller::render方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _invoke

 protected function _invoke(Controller $controller)
 {
     $result = $controller->startupProcess();
     if ($result instanceof Response) {
         return $result;
     }
     $response = $controller->invokeAction();
     if ($response !== null && !$response instanceof Response) {
         throw new LogicException('Controller actions can only Cake\\Network\\Response instances');
     }
     if (!$response && $controller->autoRender) {
         $response = $controller->render();
     } elseif (!$response) {
         $response = $controller->response;
     }
     $result = $controller->shutdownProcess();
     if ($result instanceof Response) {
         return $result;
     }
     return $response;
 }
开发者ID:markstory,项目名称:cakephp-spekkoek,代码行数:21,代码来源:ActionDispatcher.php

示例2: _unauthenticated

 /**
  * Handles unauthenticated access attempt. First the `unauthenticated()` method
  * of the last authenticator in the chain will be called. The authenticator can
  * handle sending response or redirection as appropriate and return `true` to
  * indicate no further action is necessary. If authenticator returns null this
  * method redirects user to login action. If it's an AJAX request and config
  * `ajaxLogin` is specified that element is rendered else a 403 HTTP status code
  * is returned.
  *
  * @param \Cake\Controller\Controller $controller A reference to the controller object.
  * @return \Cake\Network\Response|null Null if current action is login action
  *   else response object returned by authenticate object or Controller::redirect().
  */
 protected function _unauthenticated(Controller $controller)
 {
     if (empty($this->_authenticateObjects)) {
         $this->constructAuthenticate();
     }
     $auth = end($this->_authenticateObjects);
     $result = $auth->unauthenticated($this->request, $this->response);
     if ($result !== null) {
         return $result;
     }
     if (!$this->storage()->redirectUrl()) {
         $this->storage()->redirectUrl($this->request->here(false));
     }
     if (!$controller->request->is('ajax')) {
         $this->flash($this->_config['authError']);
         $this->storage()->redirectUrl($controller->request->here(false));
         return $controller->redirect($this->_config['loginAction']);
     }
     if (!empty($this->_config['ajaxLogin'])) {
         $controller->viewBuilder()->templatePath('Element');
         $response = $controller->render($this->_config['ajaxLogin'], $this->RequestHandler->ajaxLayout);
         $response->statusCode(403);
         return $response;
     }
     $this->response->statusCode(403);
     return $this->response;
 }
开发者ID:MillHidden,项目名称:BiellesMeusiennes,代码行数:40,代码来源:AuthComponent.php

示例3: _invoke

 /**
  * Invoke a controller's action and wrapping methods.
  *
  * @param \Cake\Controller\Controller $controller The controller to invoke.
  * @return \Cake\Network\Response The response
  * @throws \LogicException If the controller action returns a non-response value.
  */
 protected function _invoke(Controller $controller)
 {
     $this->dispatchEvent('Dispatcher.invokeController', ['controller' => $controller]);
     $result = $controller->startupProcess();
     if ($result instanceof Response) {
         return $result;
     }
     $response = $controller->invokeAction();
     if ($response !== null && !$response instanceof Response) {
         throw new LogicException('Controller actions can only return Cake\\Network\\Response or null.');
     }
     if (!$response && $controller->autoRender) {
         $response = $controller->render();
     } elseif (!$response) {
         $response = $controller->response;
     }
     $result = $controller->shutdownProcess();
     if ($result instanceof Response) {
         return $result;
     }
     return $response;
 }
开发者ID:aceat64,项目名称:cakephp,代码行数:29,代码来源:ActionDispatcher.php

示例4: execute

 /**
  * Execute a Crud action
  *
  * @param string $controllerAction Override the controller action to execute as.
  * @param array $args List of arguments to pass to the CRUD action (Usually an ID to edit / delete).
  * @return \Cake\Network\Response
  * @throws Exception If an action is not mapped.
  */
 public function execute($controllerAction = null, $args = [])
 {
     $this->_loadListeners();
     $this->_action = $controllerAction ?: $this->_action;
     $action = $this->_action;
     if (empty($args)) {
         $args = $this->_request->params['pass'];
     }
     try {
         $event = $this->trigger('beforeHandle', $this->getSubject(compact('args', 'action')));
         $response = $this->action($event->subject->action)->handle($event->subject->args);
         if ($response instanceof Response) {
             return $response;
         }
     } catch (Exception $e) {
         if (isset($e->response)) {
             return $e->response;
         }
         throw $e;
     }
     $view = null;
     $crudAction = $this->action($action);
     if (method_exists($crudAction, 'view')) {
         $view = $crudAction->view();
     }
     return $this->_controller->response = $this->_controller->render($view);
 }
开发者ID:i3i2ain,项目名称:crud,代码行数:35,代码来源:CrudComponent.php

示例5: render

 /**
  * {@inheritDoc}
  */
 public function render($view = null, $layout = null)
 {
     if ($this->_isJsonActionRequest()) {
         return $this->renderJsonAction($view, $layout);
     }
     return parent::render($view, $layout);
 }
开发者ID:wolfgang-braun,项目名称:cake-relay,代码行数:10,代码来源:AppController.php

示例6: _outputMessage

 /**
  * Generate the response using the controller object.
  *
  * @param string $template The template to render.
  * @return void
  */
 protected function _outputMessage($template)
 {
     try {
         $this->controller->render($template);
         $event = new Event('Controller.shutdown', $this->controller);
         $this->controller->afterFilter($event);
         $this->controller->response->send();
     } catch (MissingViewException $e) {
         $attributes = $e->getAttributes();
         if (isset($attributes['file']) && strpos($attributes['file'], 'error500') !== false) {
             $this->_outputMessageSafe('error500');
         } else {
             $this->_outputMessage('error500');
         }
     } catch (\Exception $e) {
         $this->_outputMessageSafe('error500');
     }
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:24,代码来源:ExceptionRenderer.php

示例7: _outputMessage

 /**
  * Generate the response using the controller object.
  *
  * @param string $template The template to render.
  * @return \Cake\Network\Response A response object that can be sent.
  */
 protected function _outputMessage($template)
 {
     try {
         $this->controller->render($template);
         return $this->_shutdown();
     } catch (MissingTemplateException $e) {
         $attributes = $e->getAttributes();
         if (isset($attributes['file']) && strpos($attributes['file'], 'error500') !== false) {
             return $this->_outputMessageSafe('error500');
         }
         return $this->_outputMessage('error500');
     } catch (MissingPluginException $e) {
         $attributes = $e->getAttributes();
         if (isset($attributes['plugin']) && $attributes['plugin'] === $this->controller->plugin) {
             $this->controller->plugin = null;
         }
         return $this->_outputMessageSafe('error500');
     } catch (Exception $e) {
         return $this->_outputMessageSafe('error500');
     }
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:27,代码来源:ExceptionRenderer.php

示例8: testBeforeRenderEventCancelsRender

 /**
  * test that a component beforeRender can change the controller view class.
  *
  * @return void
  */
 public function testBeforeRenderEventCancelsRender()
 {
     $Controller = new Controller(new Request(), new Response());
     $Controller->eventManager()->attach(function ($event) {
         return false;
     }, 'Controller.beforeRender');
     $result = $Controller->render('index');
     $this->assertInstanceOf('Cake\\Network\\Response', $result);
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:14,代码来源:ControllerTest.php

示例9: render

 /**
  * Route to a dynamic view if necessary
  * 
  * Override Controller::render()
  * 
  * If the developer requested this be a dynamic controller/action and this 
  * is one of the dynamic actions, render the proper view. Otherwise 
  * render according to normal rules.
  * 
  * @param type $view
  * @param type $layout
  * @return string
  */
 public function render($view = null, $layout = null)
 {
     if ($this->dynamic && in_array($this->request->action, $this->_crudActions)) {
         // This needs a place to put user created dynamic views?
         $view = is_null($view) ? "CrudViews.CRUD/{$this->request->action}" : $view;
         if (is_null($layout)) {
             $layout = !$this->layout ? 'default' : $this->layout;
         }
         // This still might need to detect custom action hookups
         // right now it only works for the standard views
         // but I think this is actually all we will want it to do
         // needs review and discussion
         return parent::render($view, $layout);
     } else {
         parent::render($view, $layout);
     }
     return $this->response;
 }
开发者ID:OrigamiStructures,项目名称:CrudViews,代码行数:31,代码来源:AppController.php

示例10: render

 public function render($view = false, $layout = false)
 {
     return parent::render($view, $layout);
 }
开发者ID:scherersoftware,项目名称:cake-monitor,代码行数:4,代码来源:AppController.php

示例11: fieldToggle

 /**
  * Toggle ajax field.
  *
  * @param Table $table
  * @param $id
  * @param $value
  * @param string $field
  */
 public function fieldToggle(Table $table, $id, $value, $field = 'status')
 {
     $this->_controller->serializeAjax = false;
     if (empty($id) || $value === null) {
         throw new Exception(__d('union', 'Invalid content'));
     }
     $this->_controller->viewBuilder()->layout('ajax')->templatePath('Common');
     $record = $table->get($id);
     $record->{$field} = (int) (!$value);
     if ($entity = $table->save($record)) {
         $this->_controller->set('record', $entity);
         $this->_controller->render('Union/Core.toggle');
     } else {
         throw new Exception(__d('union', 'Failed toggling field {0} to {1}', $field, $record->{$field}));
     }
 }
开发者ID:Cheren,项目名称:union,代码行数:24,代码来源:UnionComponent.php

示例12: renderModelView

 /**
  * Renders the specified view with the model
  *
  * @param  string $view   The view to render
  * @param  Entity $model  The model to pass to the view
  * @param  string $layout The layout to use for the view
  * @return \Cake\Network\Response
  */
 public function renderModelView($view = null, $model = null, $layout = null)
 {
     $this->set(compact('model'));
     return parent::render($view, $layout);
 }
开发者ID:ConnorChristie,项目名称:ChromecastMagicMirror,代码行数:13,代码来源:AppController.php

示例13: _invoke

 /**
  * Initializes the components and models a controller will be using.
  * Triggers the controller action and invokes the rendering if Controller::$autoRender
  * is true. If a response object is returned by controller action that is returned
  * else controller's $response property is returned.
  *
  * @param Controller $controller Controller to invoke
  * @return \Cake\Network\Response The resulting response object
  * @throws \Cake\Error\Exception If data returned by controller action is not an
  *   instance of Response
  */
 protected function _invoke(Controller $controller)
 {
     $controller->constructClasses();
     $result = $controller->startupProcess();
     if ($result instanceof Response) {
         return $result;
     }
     $response = $controller->invokeAction();
     if ($response !== null && !$response instanceof Response) {
         throw new Exception('Controller action can only return an instance of Response');
     }
     if (!$response && $controller->autoRender) {
         $response = $controller->render();
     } elseif (!$response) {
         $response = $controller->response;
     }
     $result = $controller->shutdownProcess();
     if ($result instanceof Response) {
         return $result;
     }
     return $response;
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:33,代码来源:Dispatcher.php


注:本文中的Cake\Controller\Controller::render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。