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


PHP Controller::getRequest方法代码示例

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


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

示例1: __get

 /**
  * Overriding parent
  *
  * @param string $name
  * @return mixed
  */
 public function __get($name)
 {
     // View
     if ($name == 'view') {
         return $this->_controllerInstance->getView();
     }
     // Request
     if ($name == 'request') {
         return $this->_controllerInstance->getRequest();
     }
     // Response
     if ($name == 'response') {
         return $this->_controllerInstance->getResponse();
     }
     // POST
     if ($name == 'post') {
         return $this->_controllerInstance->getRequest()->getPost();
     }
     // GET
     if ($name == 'query') {
         return $this->_controllerInstance->getRequest()->getQuery();
     }
     // URL parameters
     if ($name == 'params') {
         return $this->_controllerInstance->getRequest()->getParams();
     }
     // application env
     if ($name == 'appEnv') {
         return $this->_controllerInstance->getAppEnv();
     }
     parent::__get($name);
 }
开发者ID:2626suke,项目名称:curryfw,代码行数:38,代码来源:plugin_abstract.php

示例2: get_numeric_identifier

 /**
  * Utility static to avoid repetition.
  * 
  * @param Controller $controller
  * @param string $identifier e.g. 'ParentID' or 'ID'
  * @retun number
  */
 public static function get_numeric_identifier($controller, $identifier = 'ID')
 {
     // Deal-to all types of incoming data
     if (!$controller->hasMethod('currentPageID')) {
         return 0;
     }
     // Use native SS logic to deal with an identifier of 'ID'
     if ($identifier == 'ID') {
         $useId = $controller->currentPageID();
         // Otherwise it's custom
     } else {
         $params = $controller->getRequest()->requestVars();
         $idFromFunc = function () use($controller, $params, $identifier) {
             if (!isset($params[$identifier])) {
                 if (!isset($controller->urlParams[$identifier])) {
                     return 0;
                 }
                 return $controller->urlParams[$identifier];
             }
             return $params[$identifier];
         };
         $useId = $idFromFunc();
     }
     // We may have a padded string e.g. "1217 ". Without first truncating, we'd return 0 and pass tests...
     $id = (int) trim($useId);
     return !empty($id) && is_numeric($id) ? $id : 0;
 }
开发者ID:deviateltd,项目名称:silverstripe-advancedassets,代码行数:34,代码来源:SecuredFilesystem.php

示例3: __construct

 public function __construct(Controller $controller, $name)
 {
     // Set default fields
     $fields = new FieldList(HiddenField::create("AuthenticationMethod", null, $this->authenticator_class, $this), HiddenField::create('tempid', null, $controller->getRequest()->requestVar('tempid')), PasswordField::create("Password", _t('Member.PASSWORD', 'Password')), LiteralField::create('forgotPassword', sprintf('<p id="ForgotPassword"><a href="%s" target="_top">%s</a></p>', $this->getExternalLink('lostpassword'), _t('CMSMemberLoginForm.BUTTONFORGOTPASSWORD', "Forgot password?"))));
     if (Security::config()->autologin_enabled) {
         $fields->push(new CheckboxField("Remember", _t('Member.REMEMBERME', "Remember me next time?")));
     }
     // Determine returnurl to redirect to parent page
     $logoutLink = $this->getExternalLink('logout');
     if ($returnURL = $controller->getRequest()->requestVar('BackURL')) {
         $logoutLink = Controller::join_links($logoutLink, '?BackURL=' . urlencode($returnURL));
     }
     // Make actions
     $actions = new FieldList(FormAction::create('dologin', _t('CMSMemberLoginForm.BUTTONLOGIN', "Log back in")), LiteralField::create('doLogout', sprintf('<p id="doLogout"><a href="%s" target="_top">%s</a></p>', $logoutLink, _t('CMSMemberLoginForm.BUTTONLOGOUT', "Log out"))));
     parent::__construct($controller, $name, $fields, $actions);
 }
开发者ID:assertchris,项目名称:silverstripe-framework,代码行数:16,代码来源:CMSMemberLoginForm.php

示例4: __construct

 public function __construct(Response $response, Controller $controller)
 {
     $this->response = $response;
     $this->controller = $controller;
     $this->request = $controller->getRequest();
     $this->application = $controller->getApplication();
     $this->config = $this->application->getConfig();
     $this->controllerName = $this->request->getControllerName();
     $this->actionName = $this->request->getActionName();
 }
开发者ID:saiber,项目名称:livecart,代码行数:10,代码来源:ControllerPlugin.php

示例5: process

 /**
  * Executes the main functionality of the output processor
  *
  * @param \Controller $controller The relevant SilverStripe controller
  * @param mixed $result The result from the input processor
  * @return mixed|null
  */
 public function process(\Controller $controller, $result = null)
 {
     if ($controller->getRequest()->isAjax()) {
         $response = $controller->getResponse();
         $response->setStatusCode(200);
         $response->addHeader('Content-Type', 'application/json');
         $response->setBody(json_encode($result));
         return $response;
     } else {
         $controller->redirectBack();
     }
     return null;
 }
开发者ID:heyday,项目名称:heystack-ecommerce-deals,代码行数:20,代码来源:Processor.php

示例6: renderResults

 /**
  * Renders the search results into a template. Either
  * the search results template or the Atom feed
  */
 public function renderResults()
 {
     if (!$this->results) {
         $this->performSearch();
     }
     if (!$this->outputController) {
         return user_error('Call renderResults() on a DocumentationViewer instance.', E_USER_ERROR);
     }
     $request = $this->outputController->getRequest();
     $data = $this->getSearchResults($request);
     $templates = array('DocumentationViewer_results', 'DocumentationViewer');
     if ($request->requestVar('format') && $request->requestVar('format') == "atom") {
         // alter the fields for the opensearch xml.
         $title = ($title = $this->getTitle()) ? ' - ' . $title : "";
         $link = Controller::join_links($this->outputController->Link(), 'DocumentationOpenSearch_Controller/description/');
         $data->setField('Title', $data->Title . $title);
         $data->setField('DescriptionURL', $link);
         array_unshift($templates, 'OpenSearchResults');
     }
     return $this->outputController->customise($data)->renderWith($templates);
 }
开发者ID:nyeholt,项目名称:silverstripe-sapphiredocs,代码行数:25,代码来源:DocumentationSearch.php

示例7: getRequest

 function getRequest()
 {
     return parent::getRequest();
 }
开发者ID:emiliogq,项目名称:emiliogqweb,代码行数:4,代码来源:requestController.php

示例8: normalizeMethodArguments

 /**
  *
  * @param Controller $controller
  * @param string $method
  */
 private function normalizeMethodArguments($controller, $method)
 {
     $reflection = new ReflectionMethod($controller, $method);
     $numRequired = $reflection->getNumberOfRequiredParameters();
     $numCurrent = count($this->methodArguments);
     if ($numRequired > $numCurrent) {
         // If request don't have enought arguments for method set it as invalid
         $controller->getRequest()->setValid(false);
         for ($i = $numRequired - $numCurrent; $i--; $i > 0) {
             $this->methodArguments[] = NULL;
         }
     }
 }
开发者ID:czahoo,项目名称:api-framework,代码行数:18,代码来源:Framework.php

示例9: confirm

 function confirm($request)
 {
     //TODO: pretend the user confirmed, and skip straight to results. (check that this is allowed)
     //TODO: get updated shipping details from paypal??
     if ($payment = $this->payment()) {
         if ($pid = Controller::getRequest()->getVar('PayerID')) {
             $payment->PayerID = $pid;
             $payment->write();
             $payment->confirmPayment();
         }
     } else {
         //something went wrong?	..perhaps trying to pay for a payment that has already been processed
     }
     $this->doRedirect();
     return;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-payment-paypal,代码行数:16,代码来源:PayPalExpressCheckoutPayment.php

示例10: buildCacheKey

 /**
  * Builds the cache key of this form
  * 
  * @return void
  * 
  * @author Sebastian Diel <sdiel@pixeltricks.de>
  * @since 26.11.2014
  */
 public function buildCacheKey()
 {
     $customParameters = $this->getCustomParameters();
     $request = $this->controller->getRequest();
     $requestString = '';
     $formFieldString = '';
     $formFields = $this->getFormFields();
     $this->cacheKey = $this->name;
     if (count($customParameters) > 0) {
         $customParameterString = '';
         foreach ($customParameters as $parameterName => $parameterValue) {
             $customParameterString .= $parameterName . ':' . $parameterValue . ';';
         }
         $this->cacheKey .= sha1($customParameterString);
     }
     if (!is_null($request)) {
         foreach ($formFields as $fieldName => $fieldDefinition) {
             $this->addRequiredFieldParams($fieldDefinition, $fieldDefinition);
             $requestString .= $fieldName . ':' . $request[$fieldName] . ';';
             $fieldDefinitionValue = $fieldDefinition['value'];
             if (is_string($fieldDefinitionValue)) {
                 $formFieldString .= $fieldName . ':' . $fieldDefinitionValue . ';';
             } elseif (is_array($fieldDefinitionValue)) {
                 $formFieldString .= $fieldName . ':' . implode('-', $fieldDefinitionValue) . ';';
             }
         }
     }
     if (class_exists('Translatable')) {
         $requestString .= '_' . Translatable::get_current_locale();
     }
     $this->cacheKey .= sha1($requestString);
     $this->cacheKey .= sha1($formFieldString);
     $this->cacheKey .= md5($formFieldString);
     if (SecurityToken::is_enabled()) {
         $this->cacheKey .= $this->getSecurityID();
     }
     if ($this->hasCacheKeyExtension()) {
         $this->cacheKey .= $this->getCacheKeyExtension();
     }
 }
开发者ID:silvercart,项目名称:customhtmlform,代码行数:48,代码来源:CustomHtmlForm.php

示例11: is_flush

 /**
  * 
  * Detect if a flush operation is happening.
  * 
  * @param Controller $controller
  * @return boolean
  * @todo add tests
  */
 public static function is_flush(Controller $controller)
 {
     $getVars = $controller->getRequest()->getVars();
     return stristr(implode(',', array_keys($getVars)), 'flush') !== false;
 }
开发者ID:deviateltd,项目名称:silverstripe-cacheable,代码行数:13,代码来源:Cacheable.php

示例12: testGetRequest

 public function testGetRequest()
 {
     $this->container->expects($this->once())->method('getInstanceOf')->with($this->equalTo('request_service'))->will($this->returnValue($this->getMock('IRequest')));
     $this->assertThat($this->object->getRequest(), $this->isInstanceOf('IRequest'));
 }
开发者ID:juraj-blahunka,项目名称:Bachelor-Thesis,代码行数:5,代码来源:ControllerTest.php

示例13: getKeyInformation

 /**
  * @return array
  */
 public function getKeyInformation()
 {
     $request = $this->controller->getRequest();
     return array('url' => sprintf("/%s/", trim($request->getURL(true), '/')));
 }
开发者ID:Focus-Flow,项目名称:silverstripe-cacheinclude,代码行数:8,代码来源:ControllerBased.php


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