Beispiel #1
0
 public function pocCallbackGenerate($buffer)
 {
     $this->poc->setOutput($buffer);
     if ($this->httpCapture->getLevel() == $this->outputHandler->getLevel() - 1) {
         $this->poc->getPocDispatcher()->dispatch(CallbackHandlerEventNames::BEFORE_THE_DECISION_IF_WE_CAN_STORE_THE_GENERATED_CONTENT, new BaseEvent($this->poc));
         if ($this->poc->getCanICacheThisGeneratedContent()) {
             if ($this->poc->getOutput()) {
                 $headers = $this->outputHandler->headersList();
                 //Headers stored here.
                 $this->headerManipulator->storeHeadersForPreservation($headers);
                 //Remove unneeded headers.
                 $this->headerManipulator->removeHeaders();
                 $this->poc->getPocDispatcher()->dispatch(CallbackHandlerEventNames::BEFORE_STORE_OUTPUT, new BaseEvent($this->poc));
                 $this->poc->getPocDispatcher()->dispatch(CallbackHandlerEventNames::COMPRESS_OUTPUT, new BaseEvent($this->poc));
                 $this->poc->getPocDispatcher()->dispatch(CallbackHandlerEventNames::AFTER_COMPRESS_OUTPUT, new BaseEvent($this->poc));
                 $this->poc->getCache()->cacheSpecificStore($this->poc->getHasher()->getKey(), $this->poc->getOutput());
                 $this->poc->getPocDispatcher()->dispatch(CallbackHandlerEventNames::OUTPUT_STORED, new BaseEvent($this->poc));
                 $this->headerManipulator->storeHeaders();
                 $this->poc->getPocDispatcher()->dispatch(CallbackHandlerEventNames::HEADERS_STORED, new BaseEvent($this->poc));
             }
         }
         $this->poc->getPocDispatcher()->dispatch(CallbackHandlerEventNames::BEFORE_OUTPUT_SENT_TO_CLIENT_AFTER_OUTPUT_STORED, new BaseEvent($this->poc));
         if ($buffer) {
             $this->outputHandler->ObPrintCallback($this->poc->getOutput());
             return $this->poc->getOutput();
         }
     }
 }
Beispiel #2
0
 public function fetchHeaders()
 {
     $this->headersToSend = unserialize($this->poc->getCache()->fetch($this->poc->getHasher()->getKey() . self::HEADER_POSTFIX));
     if ($this->headersToSend) {
         foreach ($this->headersToSend as $header) {
             $this->poc->getEventDispatcher()->getPlugin(HttpCapture::PLUGIN_NAME)->getOutputHandler()->header($header);
         }
     }
 }