*/ class SitesTable extends ORMTable { /** * @see IORMTable::getName() * @since 1.21 * @return string */ public function getName() { return 'sites'; } /** * @see IORMTable::getFieldPrefix() * @since 1.21 * @return string */ public function getFieldPrefix() { return 'site_'; } /** * @see IORMTable::getRowClass() * @since 1.21 * @return string */ public function getRowClass() { return 'SiteObject'; } /** * @see IORMTable::getFields() * @since 1.21 * @return array */ public function getFields() { return array( 'id' => 'id', // Site data 'global_key' => 'str', 'type' => 'str', 'group' => 'str', 'source' => 'str', 'language' => 'str', 'protocol' => 'str', 'domain' => 'str', 'data' => 'array', // Site config 'forward' => 'bool', 'config' => 'array', ); } /** * @see IORMTable::getDefaults() * @since 1.21 * @return array */ public function getDefaults() { return array( 'type' => Site::TYPE_UNKNOWN, 'group' => Site::GROUP_NONE, 'source' => Site::SOURCE_LOCAL, 'data' => array(), 'forward' => false, 'config' => array(), ); } /** * Returns the class name for the provided site type. * * @since 1.21 * * @param integer $siteType * * @return string */ protected static function getClassForType( $siteType ) { global $wgSiteTypes; return array_key_exists( $siteType, $wgSiteTypes ) ? $wgSiteTypes[$siteType] : 'SiteObject'; } /** * Factory method to construct a new Site instance. * * @since 1.21 * * @param array $data * @param boolean $loadDefaults * * @return Site */ public function newRow( array $data, $loadDefaults = false ) { if ( !array_key_exists( 'type', $data ) ) { $data['type'] = Site::TYPE_UNKNOWN; } $class = static::getClassForType( $data['type'] ); return new $class( $this, $data, $loadDefaults ); } }