コード例 #1
0
 /**
  * @see ContentHandler::unserializeContent
  *
  * @param string $blob
  * @param string|null $format
  *
  * @throws MWContentSerializationException
  * @return EntityContent
  */
 public function unserializeContent($blob, $format = null)
 {
     $redirect = $this->contentCodec->decodeRedirect($blob, $format);
     if ($redirect !== null) {
         return $this->makeEntityRedirectContent($redirect);
     } else {
         $holder = new DeferredDecodingEntityHolder($this->contentCodec, $blob, $format, $this->getEntityType());
         $entityContent = $this->makeEntityContent($holder);
         return $entityContent;
     }
 }
コード例 #2
0
 /**
  * @see ContentHandler::unserializeContent
  *
  * @param string $blob
  * @param string|null $format
  *
  * @throws MWContentSerializationException
  * @return EntityContent
  */
 public function unserializeContent($blob, $format = null)
 {
     $redirect = $this->contentCodec->decodeRedirect($blob, $format);
     if ($redirect) {
         if ($redirect === null) {
             throw new MWContentSerializationException('The serialized data contains neither an Entity nor an EntityRedirect!');
         }
         return $this->makeEntityRedirectContent($redirect);
     } else {
         $holder = new DeferredDecodingEntityHolder($this->contentCodec, $blob, $format, $this->getEntityType());
         $entityContent = $this->makeEntityContent($holder);
         return $entityContent;
     }
 }
 /**
  * Construct an EntityRevision object from a database row from the revision and text tables.
  *
  * @see loadEntityBlob()
  *
  * @param object $row a row object as expected Revision::getRevisionText(). That is, it
  *        should contain the relevant fields from the revision and/or text table.
  *
  * @throws MWContentSerializationException
  * @return object[] list( EntityRevision|null $entityRevision, EntityRedirect|null $entityRedirect )
  * with either $entityRevision or $entityRedirect or both being null (but not both being non-null).
  */
 private function loadEntity($row)
 {
     $blob = $this->loadEntityBlob($row);
     $entity = $this->contentCodec->decodeEntity($blob, $row->rev_content_format);
     if ($entity) {
         $entityRevision = new EntityRevision($entity, (int) $row->rev_id, $row->rev_timestamp);
         $result = array($entityRevision, null);
     } else {
         $redirect = $this->contentCodec->decodeRedirect($blob, $row->rev_content_format);
         if (!$redirect) {
             throw new MWContentSerializationException('The serialized data contains neither an Entity nor an EntityRedirect!');
         }
         $result = array(null, $redirect);
     }
     return $result;
 }