本文整理汇总了PHP中ApiBase::extensionInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiBase::extensionInfo方法的具体用法?PHP ApiBase::extensionInfo怎么用?PHP ApiBase::extensionInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiBase
的用法示例。
在下文中一共展示了ApiBase::extensionInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getModuleSourceInfo
/**
* Returns information about the source of this module, if known
*
* Returned array is an array with the following keys:
* - path: Install path
* - name: Extension name, or "MediaWiki" for core
* - namemsg: (optional) i18n message key for a display name
* - license-name: (optional) Name of license
*
* @return array|null
*/
protected function getModuleSourceInfo()
{
global $IP;
if ($this->mModuleSource !== false) {
return $this->mModuleSource;
}
// First, try to find where the module comes from...
$rClass = new ReflectionClass($this);
$path = $rClass->getFileName();
if (!$path) {
// No path known?
$this->mModuleSource = null;
return null;
}
$path = realpath($path) ?: $path;
// Build map of extension directories to extension info
if (self::$extensionInfo === null) {
self::$extensionInfo = array(realpath(__DIR__) ?: __DIR__ => array('path' => $IP, 'name' => 'MediaWiki', 'license-name' => 'GPL-2.0+'), realpath("{$IP}/extensions") ?: "{$IP}/extensions" => null);
$keep = array('path' => null, 'name' => null, 'namemsg' => null, 'license-name' => null);
foreach ($this->getConfig()->get('ExtensionCredits') as $group) {
foreach ($group as $ext) {
if (!isset($ext['path']) || !isset($ext['name'])) {
// This shouldn't happen, but does anyway.
continue;
}
$extpath = $ext['path'];
if (!is_dir($extpath)) {
$extpath = dirname($extpath);
}
self::$extensionInfo[realpath($extpath) ?: $extpath] = array_intersect_key($ext, $keep);
}
}
foreach (ExtensionRegistry::getInstance()->getAllThings() as $ext) {
$extpath = $ext['path'];
if (!is_dir($extpath)) {
$extpath = dirname($extpath);
}
self::$extensionInfo[realpath($extpath) ?: $extpath] = array_intersect_key($ext, $keep);
}
}
// Now traverse parent directories until we find a match or run out of
// parents.
do {
if (array_key_exists($path, self::$extensionInfo)) {
// Found it!
$this->mModuleSource = self::$extensionInfo[$path];
return $this->mModuleSource;
}
$oldpath = $path;
$path = dirname($path);
} while ($path !== $oldpath);
// No idea what extension this might be.
$this->mModuleSource = null;
return null;
}