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


PHP Http::setHeader方法代码示例

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


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

示例1: testRepresentJson

 /**
  * Test setting body in JSON format
  */
 public function testRepresentJson()
 {
     $this->model->setHeader('Content-Type', 'text/javascript');
     $this->model->representJson('json_string');
     $this->assertEquals('application/json', $this->model->getHeader('Content-Type')->getFieldValue());
     $this->assertEquals('json_string', $this->model->getBody('default'));
 }
开发者ID:nja78,项目名称:magento2,代码行数:10,代码来源:HttpTest.php

示例2: beforeSendResponse

 /**
  * @param \Magento\Framework\App\Response\Http $subject
  * @return void
  * @codeCoverageIgnore
  */
 public function beforeSendResponse(\Magento\Framework\App\Response\Http $subject)
 {
     foreach ($this->headerProviders as $provider) {
         if ($provider->canApply()) {
             $subject->setHeader($provider->getName(), $provider->getValue());
         }
     }
 }
开发者ID:VoblaSmile,项目名称:php56-magento2-data,代码行数:13,代码来源:HeaderManager.php

示例3: handleDeveloperMode

 /**
  * Error handler for developer mode
  *
  * @param Bootstrap $bootstrap
  * @param \Exception $exception
  * @return bool
  */
 private function handleDeveloperMode(Bootstrap $bootstrap, \Exception $exception)
 {
     if ($bootstrap->isDeveloperMode()) {
         $this->_response->setHttpResponseCode(500);
         $this->_response->setHeader('Content-Type', 'text/plain');
         $this->_response->setBody($exception->getMessage() . "\n" . $exception->getTraceAsString());
         $this->_response->sendResponse();
         return true;
     }
     return false;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:18,代码来源:Http.php

示例4: execute

 /**
  * Execute method.
  */
 public function execute()
 {
     $attribute = $this->getRequest()->getParam('attribute');
     $conditionName = $this->getRequest()->getParam('condition');
     $valueName = $this->getRequest()->getParam('value');
     if ($attribute && $conditionName && $valueName) {
         $type = $this->ruleType->getInputType($attribute);
         $conditionOptions = $this->ruleCondition->getInputTypeOptions($type);
         $response['condition'] = $this->_getOptionHtml('conditions', $conditionName, $conditionOptions);
         $elmType = $this->ruleValue->getValueElementType($attribute);
         if ($elmType == 'select') {
             $valueOptions = $this->ruleValue->getValueSelectOptions($attribute);
             $response['cvalue'] = $this->_getOptionHtml('cvalue', $valueName, $valueOptions);
         } elseif ($elmType == 'text') {
             $html = "<input style='width:160px' title='cvalue' class='' id='' name={$valueName} />";
             $response['cvalue'] = $html;
         }
         $this->http->getHeaders()->clearHeaders();
         $this->http->setHeader('Content-Type', 'application/json')->setBody($this->jsonEncoder->encode($response));
     }
 }
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:24,代码来源:Ajax.php

示例5: execute

 /**
  * Execute method.
  *
  * @return $this
  */
 public function execute()
 {
     $id = $this->getRequest()->getParam('ruleid');
     $attribute = $this->getRequest()->getParam('attribute');
     $arrayKey = $this->getRequest()->getParam('arraykey');
     $conditionName = $this->getRequest()->getParam('condition');
     $valueName = $this->getRequest()->getParam('value');
     if ($arrayKey && $id && $attribute && $conditionName && $valueName) {
         $rule = $this->rulesFactory->create()->load($id);
         //rule not found
         if (!$rule->getId()) {
             $this->http->getHeaders()->clearHeaders();
             return $this->http->setHeader('Content-Type', 'application/json')->setBody('Rule not found!');
         }
         $conditions = $rule->getCondition();
         $condition = $conditions[$arrayKey];
         $selectedConditions = $condition['conditions'];
         $selectedValues = $condition['cvalue'];
         $type = $this->ruleType->getInputType($attribute);
         $conditionOptions = $this->ruleCondition->getInputTypeOptions($type);
         $response['condition'] = str_replace('value="' . $selectedConditions . '"', 'value="' . $selectedConditions . '"' . 'selected="selected"', $this->getOptionHtml('conditions', $conditionName, $conditionOptions));
         $elmType = $this->ruleValue->getValueElementType($attribute);
         if ($elmType == 'select' or $selectedConditions == 'null') {
             $isEmpty = false;
             if ($selectedConditions == 'null') {
                 $isEmpty = true;
             }
             $valueOptions = $this->ruleValue->getValueSelectOptions($attribute, $isEmpty);
             $response['cvalue'] = str_replace('value="' . $selectedValues . '"', 'value="' . $selectedValues . '"' . 'selected="selected"', $this->getOptionHtml('cvalue', $valueName, $valueOptions));
         } elseif ($elmType == 'text') {
             $html = "<input style='width:160px' title='cvalue' name='{$valueName}' value='{$selectedValues}'/>";
             $response['cvalue'] = $html;
         }
         $this->http->getHeaders()->clearHeaders();
         $this->http->setHeader('Content-Type', 'application/json')->setBody($this->jsonEncoder->encode($response));
     }
 }
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:42,代码来源:Selected.php

示例6: handleDeveloperMode

 /**
  * Error handler for developer mode
  *
  * @param Bootstrap $bootstrap
  * @param \Exception $exception
  * @return bool
  */
 private function handleDeveloperMode(Bootstrap $bootstrap, \Exception $exception)
 {
     if ($bootstrap->isDeveloperMode()) {
         if (Bootstrap::ERR_IS_INSTALLED == $bootstrap->getErrorCode()) {
             try {
                 $this->redirectToSetup($bootstrap, $exception);
                 return true;
             } catch (\Exception $e) {
                 $exception = $e;
             }
         }
         $this->_response->setHttpResponseCode(500);
         $this->_response->setHeader('Content-Type', 'text/plain');
         $this->_response->setBody($this->buildContentFromException($exception));
         $this->_response->sendResponse();
         return true;
     }
     return false;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:26,代码来源:Http.php

示例7: addDebugHeader

 /**
  * Add additional header for debug purpose
  *
  * @param ResponseHttp $response
  * @param string $name
  * @param string $value
  * @param bool $replace
  * @return void
  */
 protected function addDebugHeader(ResponseHttp $response, $name, $value, $replace = false)
 {
     if ($this->state->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
         $response->setHeader($name, $value, $replace);
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:BuiltinPlugin.php

示例8: setHeader

 /**
  * {@inheritdoc}
  */
 public function setHeader($name, $value, $replace = false)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'setHeader');
     if (!$pluginInfo) {
         return parent::setHeader($name, $value, $replace);
     } else {
         return $this->___callPlugins('setHeader', func_get_args(), $pluginInfo);
     }
 }
开发者ID:HaonanXu,项目名称:der-snack-backup,代码行数:12,代码来源:Interceptor.php


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