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


PHP Zend_Controller_Response_Http::getBody方法代码示例

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


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

示例1: testCustomInflectorUsesViewRendererTargetWhenPassedInWithReferenceFlag

    public function testCustomInflectorUsesViewRendererTargetWhenPassedInWithReferenceFlag()
    {
        $this->request->setModuleName('bar')
                      ->setControllerName('index')
                      ->setActionName('test');
        $controller = new Bar_IndexController($this->request, $this->response, array());

        $this->helper->view->addBasePath($this->basePath . '/_files/modules/bar/views');

        require_once 'Zend/Filter/PregReplace.php';
        require_once 'Zend/Filter/Word/UnderscoreToSeparator.php';
        
        $inflector = new Zend_Filter_Inflector('test.phtml');
        $inflector->addRules(array(
            ':module'     => array('Word_CamelCaseToDash', 'stringToLower'),
            ':controller' => array('Word_CamelCaseToDash', new Zend_Filter_Word_UnderscoreToSeparator(DIRECTORY_SEPARATOR), 'StringToLower'),
            ':action'     => array(
                'Word_CamelCaseToDash', 
                new Zend_Filter_PregReplace('/[^a-z0-9]+/i', '-'),
                'StringToLower'
            ),
        ));
        $this->helper->setInflector($inflector, true);

        $this->helper->render();
        $body = $this->response->getBody();
        $this->assertContains('Rendered index/test.phtml in bar module', $body);
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:28,代码来源:ViewRendererTest.php

示例2: testPreDispatchNonWhitelistedActionViaAjaxRequest

 public function testPreDispatchNonWhitelistedActionViaAjaxRequest()
 {
     $this->request->setHeader('X_REQUESTED_WITH', 'XMLHttpRequest')->setModuleName('default')->setControllerName('foo')->setActionName('home');
     $this->plugin->preDispatch($this->request);
     $this->assertEquals(500, $this->response->getHttpResponseCode());
     $this->assertEquals(json_encode(array('redirect' => '/user/login')), $this->response->getBody());
 }
开发者ID:rexmac,项目名称:zyndax,代码行数:7,代码来源:AuthTest.php

示例3: testCorrectViewHelperPathShouldBePropagatedWhenSubControllerInvokedInDefaultModule

 public function testCorrectViewHelperPathShouldBePropagatedWhenSubControllerInvokedInDefaultModule()
 {
     require_once $this->basePath . '/_files/modules/default/controllers/Admin/HelperController.php';
     $this->request->setControllerName('admin_helper')->setActionName('render');
     $controller = new Admin_HelperController($this->request, $this->response, array());
     $this->helper->render();
     $body = $this->response->getBody();
     $this->assertContains('SampleZfHelper invoked', $body, 'Received ' . $body);
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:9,代码来源:ViewRendererTest.php

示例4: testPostDispatchDoesNotRenderViewWhenNoViewRendererSet

 public function testPostDispatchDoesNotRenderViewWhenNoViewRendererSet()
 {
     $this->request->setModuleName('bar')->setControllerName('index')->setActionName('index');
     $this->front->setParam('noViewRenderer', true);
     $controller = new Bar_IndexController($this->request, $this->response, array());
     $this->helper->postDispatch();
     $body = $this->response->getBody();
     $this->assertTrue(empty($body));
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:9,代码来源:ViewRendererTest.php

示例5: containsJson

 /**
  * Asserts that the response contains JSON data.
  *
  * Also checks if the content type header is compatible
  * to JSON data.
  */
 public function containsJson()
 {
     $content = $this->response->getBody();
     try {
         Zend_Json::decode($content);
     } catch (Zend_Json_Exception $e) {
         PHPUnit_Framework_Assert::fail('Invalid JSON data found: ' . $e->getMessage());
     }
     $this->headerEquals('Content-Type', 'application/json');
 }
开发者ID:matthimatiker,项目名称:molcomponents,代码行数:16,代码来源:HttpResponse.php

示例6: prepareContent

 /**
  * Prepare response body before caching
  *
  * @param Zend_Controller_Response_Http $response
  * @return string
  */
 public function prepareContent(Zend_Controller_Response_Http $response)
 {
     $content = $response->getBody();
     $placeholders = array();
     preg_match_all(Enterprise_PageCache_Model_Container_Placeholder::HTML_NAME_PATTERN, $content, $placeholders, PREG_PATTERN_ORDER);
     $placeholders = array_unique($placeholders[1]);
     try {
         foreach ($placeholders as $definition) {
             $this->_placeholder = Mage::getModel('enterprise_pagecache/container_placeholder', $definition);
             $content = preg_replace_callback($this->_placeholder->getPattern(), array($this, '_getPlaceholderReplacer'), $content);
         }
         $this->_placeholder = null;
     } catch (Exception $e) {
         $this->_placeholder = null;
         throw $e;
     }
     return $content;
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:24,代码来源:Default.php

示例7: cachePage

 /**
  * Handles logic for caching pages.  Currently checks the root block for the
  * "CachePageFlag".  Pages are only cached if the user is not logged in and does
  * not have items in their cart.
  *
  * @param $observer
  * @return void
  */
 public function cachePage(Zend_Controller_Response_Http $response)
 {
     // Check if cache flag is set
     $rootBlock = Mage::app()->getLayout()->getBlock('root');
     if ($rootBlock && $rootBlock->getCachePageFlag()) {
         if ($this->passesConditions($rootBlock->getCachePageConditions())) {
             $cache = Mage::app()->getCache();
             $id = $this->generateFPCId();
             if ($rootBlock->getCachePageExpires() > 0) {
                 $expires = $rootBlock->getCachePageExpires();
             } else {
                 //default expires
                 $expires = Mage::getStoreConfig(Brim_PageCache_Model_Config::XML_PATH_EXPIRES);
             }
             $storageObject = Mage::getModel('brim_pagecache/storage');
             if (Mage::getStoreConfig(Brim_PageCache_Model_Config::XML_PATH_ENABLE_MINIFY_HTML)) {
                 // Minify the response body.  Helps save on cache storage space
                 // Basic grouped product page 34k in size was about 28K minified,
                 $minifyBody = Brim_PageCache_Model_Minify_HTML::minify($response->getBody());
                 $response->setBody($minifyBody);
             }
             $storageObject->setResponse($response);
             /**
              * Block update data contains partial layouts for each block.  Allows us to regenerate each one
              * with out loosing customizations.
              */
             $storageObject->setBlockUpdateData($this->getBlockUpdateData());
             // Set the expected expires time for this page
             $date = Mage::app()->getLocale()->date()->addSecond($expires);
             $storageObject->setData(self::RESPONSE_HEADER_EXPIRES_DATE, $date->get(Zend_Date::RFC_1123));
             $storageObject->setData(self::RESPONSE_HEADER_EXPIRES, $expires);
             $storageObject->setData(self::RESPONSE_HEADER_CONDITIONS, $rootBlock->getCachePageConditions());
             $storageObject->setData(self::RESPONSE_HEADER_STORE, Mage::app()->getStore()->getCode());
             $storageObject->setData(self::RESPONSE_HEADER_ORIG_TIME, microtime(true) - self::$_start_time);
             $this->debug('Saving page with cache id : ' . $id);
             if (($product = Mage::registry('product')) != null) {
                 $this->devDebug('Registering Tag: ' . self::FPC_TAG . '_PRODUCT_' . $product->getId());
                 $this->registerPageTags(self::FPC_TAG . '_PRODUCT_' . $product->getId());
             }
             if (($category = Mage::registry('current_category')) != null && $product == null) {
                 $this->devDebug('Registering Tag: ' . self::FPC_TAG . '_CATEGORY_' . $category->getId());
                 $this->registerPageTags(self::FPC_TAG . '_CATEGORY_' . $category->getId());
             }
             $cache->save(serialize($storageObject), $id, $this->getPageTags(), $expires);
         } else {
             // failed conditions
             if ($response->canSendHeaders(false)) {
                 $response->setHeader(self::RESPONSE_HEADER_FAILED, $this->_failed_conditions);
             }
         }
     } else {
         if ($response->canSendHeaders(false)) {
             // page not set to cache
             $response->setHeader(self::RESPONSE_HEADER_FAILED, 'no_cache');
         }
     }
 }
开发者ID:AvalonKnight,项目名称:brim_pagecache-2.1.3,代码行数:65,代码来源:Engine.php

示例8: prepareContent

 /**
  * Prepare response body before caching
  *
  * @param Zend_Controller_Response_Http $response
  * @return string
  */
 public function prepareContent(Zend_Controller_Response_Http $response)
 {
     return $this->replaceContentToPlaceholderReplacer($response->getBody());
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:10,代码来源:Default.php

示例9: _sendResponse

 protected function _sendResponse($httpCode, $code, $message)
 {
     // TODO Why is sometimes sending response twice??? :S
     if (self::$responseSent) {
         return;
     }
     if (!($response = Zend_Controller_Front::getInstance()->getResponse())) {
         $response = new Zend_Controller_Response_Http();
     }
     $response->setHttpResponseCode($httpCode);
     if (!$response->getBody()) {
         $body = array('code' => $code, 'message' => $message);
         $response->setBody(Zend_Json::encode($body));
     }
     if ($response->canSendHeaders()) {
         $response->clearHeaders();
         $response->setHeader('Content-Type', 'application/json');
         $response->sendResponse();
         self::$responseSent = true;
     }
     exit;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:22,代码来源:Bootstrap.php

示例10: processResponse

 /**
  * Process response body by specific request
  *
  * @param Zend_Controller_Response_Http $response response
  * @param Zend_Controller_Request_Http  $request  request
  *
  * @return Smile_MageCache_Model_Engine_Default
  */
 public function processResponse(Zend_Controller_Response_Http $response, Zend_Controller_Request_Http $request)
 {
     /*
      * Check request and response.
      * Note: Deal only with 200 for the moment
      */
     if ($this->canProcessRequest($request) && $response->getHttpResponseCode() == 200) {
         $cacheId = $this->getRequestCacheId();
         $content = $response->getBody();
         if (function_exists('gzcompress')) {
             $content = gzcompress($content);
         }
         $res = $this->_adapter->save($content, $cacheId, $this->getRequestTags());
         $this->setMetadata('response_headers', $response->getHeaders());
         $this->_saveMetadata();
     }
     return $this;
 }
开发者ID:lmcro,项目名称:magecache,代码行数:26,代码来源:Default.php


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