本文整理汇总了PHP中Magento\Framework\App\Response\Http::getHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::getHeaders方法的具体用法?PHP Http::getHeaders怎么用?PHP Http::getHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Response\Http
的用法示例。
在下文中一共展示了Http::getHeaders方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDisplay
public function testDisplay()
{
$this->markTestSkipped('Remove it when task(MAGETWO-33495) will be fixed');
$this->_response->expects($this->atLeastOnce())->method('sendHeaders');
$this->_request->expects($this->atLeastOnce())->method('getHeader');
$stat = (include __DIR__ . '/_files/timers.php');
$this->_output->display($stat);
$actualHeaders = $this->_response->getHeaders();
$this->assertNotEmpty($actualHeaders);
$actualProtocol = false;
$actualProfilerData = false;
foreach ($actualHeaders as $oneHeader) {
$headerName = $oneHeader->getFieldName();
$headerValue = $oneHeader->getFieldValue();
if (!$actualProtocol && $headerName == 'X-Wf-Protocol-1') {
$actualProtocol = $headerValue;
}
if (!$actualProfilerData && $headerName == 'X-Wf-1-1-1-1') {
$actualProfilerData = $headerValue;
}
}
$this->assertNotEmpty($actualProtocol, 'Cannot get protocol header');
$this->assertNotEmpty($actualProfilerData, 'Cannot get profiler header');
$this->assertContains('Protocol/JsonStream', $actualProtocol);
$this->assertRegExp('/"Type":"TABLE","Label":"Code Profiler \\(Memory usage: real - \\d+, emalloc - \\d+\\)"/', $actualProfilerData);
$this->assertContains('[' . '["Timer Id","Time","Avg","Cnt","Emalloc","RealMem"],' . '["root","0.080000","0.080000","1","1,000","50,000"],' . '[". init","0.040000","0.040000","1","200","2,500"],' . '[". . init_store","0.020000","0.010000","2","100","2,000"],' . '["system","0.030000","0.015000","2","400","20,000"]' . ']', $actualProfilerData);
}
示例2: 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));
}
}
示例3: 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));
}
}
示例4: getHeaders
/**
* {@inheritdoc}
*/
public function getHeaders()
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getHeaders');
if (!$pluginInfo) {
return parent::getHeaders();
} else {
return $this->___callPlugins('getHeaders', func_get_args(), $pluginInfo);
}
}