* @license GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
-class Site {
+class Site implements Serializable {
const TYPE_UNKNOWN = 'unknown';
const TYPE_MEDIAWIKI = 'mediawiki';
const PATH_LINK = 'link';
+
+ /**
+ * A version ID that identifies the serialization structure used by getSerializationData()
+ * and unserialize(). This is useful for constructing cache keys in cases where the cache relies
+ * on serialization for storing the SiteList.
+ *
+ * @var string A string uniquely identifying the version of the serialization structure.
+ */
+ const SERIAL_VERSION_ID = '2013-01-23';
+
/**
* @since 1.21
*
}
if ( $pageName !== false ) {
- $url = str_replace( '$1', rawurlencode( $pageName ), $url ) ;
+ $url = str_replace( '$1', rawurlencode( $pageName ), $url );
}
return $url;
}
}
- // TODO: config
-
/**
* @since 1.21
*
return new Site();
}
+ /**
+ * @see Serializable::serialize
+ *
+ * @since 1.21
+ *
+ * @return string
+ */
+ public function serialize() {
+ $fields = array(
+ 'globalid' => $this->globalId,
+ 'type' => $this->type,
+ 'group' => $this->group,
+ 'source' => $this->source,
+ 'language' => $this->languageCode,
+ 'localids' => $this->localIds,
+ 'config' => $this->extraConfig,
+ 'data' => $this->extraData,
+ 'forward' => $this->forward,
+ 'internalid' => $this->internalId,
+
+ );
+
+ return serialize( $fields );
+ }
+
+ /**
+ * @see Serializable::unserialize
+ *
+ * @since 1.21
+ *
+ * @param string $serialized
+ */
+ public function unserialize( $serialized ) {
+ $fields = unserialize( $serialized );
+
+ $this->__construct( $fields['type'] );
+
+ $this->setGlobalId( $fields['globalid'] );
+ $this->setGroup( $fields['group'] );
+ $this->setSource( $fields['source'] );
+ $this->setLanguageCode( $fields['language'] );
+ $this->localIds = $fields['localids'];
+ $this->setExtraConfig( $fields['config'] );
+ $this->setExtraData( $fields['data'] );
+ $this->setForward( $fields['forward'] );
+ $this->setInternalId( $fields['internalid'] );
+ }
+
}
/**
* @deprecated
*/
-class SiteObject extends Site {}
\ No newline at end of file
+class SiteObject extends Site {}