当前位置: 首页>>代码示例>>PHP>>正文


PHP Site::newForType方法代码示例

本文整理汇总了PHP中Site::newForType方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::newForType方法的具体用法?PHP Site::newForType怎么用?PHP Site::newForType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Site的用法示例。


在下文中一共展示了Site::newForType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadSites

 /**
  * Fetches the site from the database and loads them into the sites field.
  *
  * @since 1.25
  */
 protected function loadSites()
 {
     $this->sites = new SiteList();
     $dbr = $this->dbLoadBalancer->getConnection(DB_SLAVE);
     $res = $dbr->select('sites', ['site_id', 'site_global_key', 'site_type', 'site_group', 'site_source', 'site_language', 'site_protocol', 'site_domain', 'site_data', 'site_forward', 'site_config'], '', __METHOD__, ['ORDER BY' => 'site_global_key']);
     foreach ($res as $row) {
         $site = Site::newForType($row->site_type);
         $site->setGlobalId($row->site_global_key);
         $site->setInternalId((int) $row->site_id);
         $site->setForward((bool) $row->site_forward);
         $site->setGroup($row->site_group);
         $site->setLanguageCode($row->site_language === '' ? null : $row->site_language);
         $site->setSource($row->site_source);
         $site->setExtraData(unserialize($row->site_data));
         $site->setExtraConfig(unserialize($row->site_config));
         $this->sites[] = $site;
     }
     // Batch load the local site identifiers.
     $ids = $dbr->select('site_identifiers', ['si_site', 'si_type', 'si_key'], [], __METHOD__);
     foreach ($ids as $id) {
         if ($this->sites->hasInternalId($id->si_site)) {
             $site = $this->sites->getSiteByInternalId($id->si_site);
             $site->addLocalId($id->si_type, $id->si_key);
             $this->sites->setSite($site);
         }
     }
     $this->dbLoadBalancer->reuseConnection($dbr);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:33,代码来源:DBSiteStore.php

示例2: siteFromRow

 /**
  * Returns a new Site object constructed from the provided ORMRow.
  *
  * @since 1.25
  *
  * @param ORMRow $siteRow
  *
  * @return Site
  */
 protected function siteFromRow(ORMRow $siteRow)
 {
     $site = Site::newForType($siteRow->getField('type', Site::TYPE_UNKNOWN));
     $site->setGlobalId($siteRow->getField('global_key'));
     $site->setInternalId($siteRow->getField('id'));
     if ($siteRow->hasField('forward')) {
         $site->setForward($siteRow->getField('forward'));
     }
     if ($siteRow->hasField('group')) {
         $site->setGroup($siteRow->getField('group'));
     }
     if ($siteRow->hasField('language')) {
         $site->setLanguageCode($siteRow->getField('language') === '' ? null : $siteRow->getField('language'));
     }
     if ($siteRow->hasField('source')) {
         $site->setSource($siteRow->getField('source'));
     }
     if ($siteRow->hasField('data')) {
         $site->setExtraData($siteRow->getField('data'));
     }
     if ($siteRow->hasField('config')) {
         $site->setExtraConfig($siteRow->getField('config'));
     }
     return $site;
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:34,代码来源:DBSiteStore.php

示例3: testImportFromFile

 public function testImportFromFile()
 {
     $foo = Site::newForType(Site::TYPE_UNKNOWN);
     $foo->setGlobalId('Foo');
     $acme = Site::newForType(Site::TYPE_UNKNOWN);
     $acme->setGlobalId('acme.com');
     $acme->setGroup('Test');
     $acme->addLocalId(Site::ID_INTERWIKI, 'acme');
     $acme->setPath(Site::PATH_LINK, 'http://acme.com/');
     $dewiki = Site::newForType(Site::TYPE_MEDIAWIKI);
     $dewiki->setGlobalId('dewiki');
     $dewiki->setGroup('wikipedia');
     $dewiki->setForward(true);
     $dewiki->addLocalId(Site::ID_INTERWIKI, 'wikipedia');
     $dewiki->addLocalId(Site::ID_EQUIVALENT, 'de');
     $dewiki->setPath(Site::PATH_LINK, 'http://de.wikipedia.org/w/');
     $dewiki->setPath(MediaWikiSite::PATH_PAGE, 'http://de.wikipedia.org/wiki/');
     $dewiki->setSource('meta.wikimedia.org');
     $importer = $this->newSiteImporter(array($foo, $acme, $dewiki), 0);
     $file = __DIR__ . '/SiteImporterTest.xml';
     $importer->importFromFile($file);
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:22,代码来源:SiteImporterTest.php

示例4: makeSite

 /**
  * @param DOMElement $siteElement
  *
  * @return Site
  * @throws InvalidArgumentException
  */
 public function makeSite(DOMElement $siteElement)
 {
     if ($siteElement->tagName !== 'site') {
         throw new InvalidArgumentException('Expected <site> tag, found ' . $siteElement->tagName);
     }
     $type = $this->getAttributeValue($siteElement, 'type', Site::TYPE_UNKNOWN);
     $site = Site::newForType($type);
     $site->setForward($this->hasChild($siteElement, 'forward'));
     $site->setGlobalId($this->getChildText($siteElement, 'globalid'));
     $site->setGroup($this->getChildText($siteElement, 'group', Site::GROUP_NONE));
     $site->setSource($this->getChildText($siteElement, 'source', Site::SOURCE_LOCAL));
     $pathTags = $siteElement->getElementsByTagName('path');
     for ($i = 0; $i < $pathTags->length; $i++) {
         $pathElement = $pathTags->item($i);
         $pathType = $this->getAttributeValue($pathElement, 'type');
         $path = $pathElement->textContent;
         $site->setPath($pathType, $path);
     }
     $idTags = $siteElement->getElementsByTagName('localid');
     for ($i = 0; $i < $idTags->length; $i++) {
         $idElement = $idTags->item($i);
         $idType = $this->getAttributeValue($idElement, 'type');
         $id = $idElement->textContent;
         $site->addLocalId($idType, $id);
     }
     //@todo: import <data>
     //@todo: import <config>
     return $site;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:35,代码来源:SiteImporter.php

示例5: provideRoundTrip

 public function provideRoundTrip()
 {
     $foo = Site::newForType(Site::TYPE_UNKNOWN);
     $foo->setGlobalId('Foo');
     $acme = Site::newForType(Site::TYPE_UNKNOWN);
     $acme->setGlobalId('acme.com');
     $acme->setGroup('Test');
     $acme->addLocalId(Site::ID_INTERWIKI, 'acme');
     $acme->setPath(Site::PATH_LINK, 'http://acme.com/');
     $dewiki = Site::newForType(Site::TYPE_MEDIAWIKI);
     $dewiki->setGlobalId('dewiki');
     $dewiki->setGroup('wikipedia');
     $dewiki->setForward(true);
     $dewiki->addLocalId(Site::ID_INTERWIKI, 'wikipedia');
     $dewiki->addLocalId(Site::ID_EQUIVALENT, 'de');
     $dewiki->setPath(Site::PATH_LINK, 'http://de.wikipedia.org/w/');
     $dewiki->setPath(MediaWikiSite::PATH_PAGE, 'http://de.wikipedia.org/wiki/');
     $dewiki->setSource('meta.wikimedia.org');
     return array('empty' => array(new SiteList()), 'some' => array(new SiteList(array($foo, $acme, $dewiki))));
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:20,代码来源:SiteExporterTest.php

示例6: newSiteFromArray

 /**
  * @param array $data
  *
  * @return Site
  */
 private function newSiteFromArray(array $data)
 {
     $siteType = array_key_exists('type', $data) ? $data['type'] : Site::TYPE_UNKNOWN;
     $site = Site::newForType($siteType);
     $site->setGlobalId($data['globalid']);
     $site->setForward($data['forward']);
     $site->setGroup($data['group']);
     $site->setLanguageCode($data['language']);
     $site->setSource($data['source']);
     $site->setExtraData($data['data']);
     $site->setExtraConfig($data['config']);
     foreach ($data['identifiers'] as $identifier) {
         $site->addLocalId($identifier['type'], $identifier['key']);
     }
     return $site;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:21,代码来源:FileBasedSiteLookup.php


注:本文中的Site::newForType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。