Exemplo n.º 1
0
 private function getRawData()
 {
     if ($this->rawData === null) {
         $type = $this->getDataType();
         $data = $this->getData();
         switch ($type) {
             case self::DATATYPE_TEXT:
                 // In this storage type, the changes are stored on the object.
                 $data = $data;
                 break;
             case self::DATATYPE_FILE:
             default:
                 throw new Exception(pht('Hunk has unsupported data type "%s"!', $type));
         }
         $format = $this->getDataFormat();
         switch ($format) {
             case self::DATAFORMAT_RAW:
                 // In this format, the changes are stored as-is.
                 $data = $data;
                 break;
             case self::DATAFORMAT_DEFLATED:
                 $data = PhabricatorCaches::inflateData($data);
                 break;
             default:
                 throw new Exception(pht('Hunk has unsupported data encoding "%s"!', $type));
         }
         $this->rawData = $data;
     }
     return $this->rawData;
 }
 private function didReadValue($format, $value)
 {
     switch ($format) {
         case self::CACHE_FORMAT_RAW:
             return $value;
         case self::CACHE_FORMAT_DEFLATE:
             return PhabricatorCaches::inflateData($value);
         default:
             throw new Exception(pht('Unknown cache format.'));
     }
 }