本文整理汇总了PHP中ResourceLoaderModule::expandRelativePaths方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceLoaderModule::expandRelativePaths方法的具体用法?PHP ResourceLoaderModule::expandRelativePaths怎么用?PHP ResourceLoaderModule::expandRelativePaths使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResourceLoaderModule
的用法示例。
在下文中一共展示了ResourceLoaderModule::expandRelativePaths方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preloadModuleInfo
/**
* Load information stored in the database about modules.
*
* This method grabs modules dependencies from the database and updates modules
* objects.
*
* This is not inside the module code because it is much faster to
* request all of the information at once than it is to have each module
* requests its own information. This sacrifice of modularity yields a substantial
* performance improvement.
*
* @param array $modules List of module names to preload information for
* @param ResourceLoaderContext $context Context to load the information within
*/
public function preloadModuleInfo(array $modules, ResourceLoaderContext $context)
{
if (!count($modules)) {
// Or else Database*::select() will explode, plus it's cheaper!
return;
}
$dbr = wfGetDB(DB_SLAVE);
$skin = $context->getSkin();
$lang = $context->getLanguage();
// Batched version of ResourceLoaderModule::getFileDependencies
$vary = "{$skin}|{$lang}";
$res = $dbr->select('module_deps', array('md_module', 'md_deps'), array('md_module' => $modules, 'md_skin' => $vary), __METHOD__);
// Prime in-object cache values for each module
$modulesWithDeps = array();
foreach ($res as $row) {
$module = $this->getModule($row->md_module);
if ($module) {
$module->setFileDependencies($context, ResourceLoaderModule::expandRelativePaths(FormatJson::decode($row->md_deps, true)));
$modulesWithDeps[] = $row->md_module;
}
}
// Register the absence of a dependency row too
foreach (array_diff($modules, $modulesWithDeps) as $name) {
$module = $this->getModule($name);
if ($module) {
$this->getModule($name)->setFileDependencies($context, array());
}
}
// Get message blob mtimes. Only do this for modules with messages
$modulesWithMessages = array();
foreach ($modules as $name) {
$module = $this->getModule($name);
if ($module && count($module->getMessages())) {
$modulesWithMessages[] = $name;
}
}
$modulesWithoutMessages = array_flip($modules);
// Will be trimmed down by the loop below
if (count($modulesWithMessages)) {
$res = $dbr->select('msg_resource', array('mr_resource', 'mr_timestamp'), array('mr_resource' => $modulesWithMessages, 'mr_lang' => $lang), __METHOD__);
foreach ($res as $row) {
$module = $this->getModule($row->mr_resource);
if ($module) {
$module->setMsgBlobMtime($lang, wfTimestamp(TS_UNIX, $row->mr_timestamp));
unset($modulesWithoutMessages[$row->mr_resource]);
}
}
}
foreach (array_keys($modulesWithoutMessages) as $name) {
$module = $this->getModule($name);
if ($module) {
$module->setMsgBlobMtime($lang, 1);
}
}
}
示例2: preloadModuleInfo
/**
* Load information stored in the database about modules.
*
* This method grabs modules dependencies from the database and updates modules
* objects.
*
* This is not inside the module code because it is much faster to
* request all of the information at once than it is to have each module
* requests its own information. This sacrifice of modularity yields a substantial
* performance improvement.
*
* @param array $moduleNames List of module names to preload information for
* @param ResourceLoaderContext $context Context to load the information within
*/
public function preloadModuleInfo(array $moduleNames, ResourceLoaderContext $context)
{
if (!$moduleNames) {
// Or else Database*::select() will explode, plus it's cheaper!
return;
}
$dbr = wfGetDB(DB_SLAVE);
$skin = $context->getSkin();
$lang = $context->getLanguage();
// Batched version of ResourceLoaderModule::getFileDependencies
$vary = "{$skin}|{$lang}";
$res = $dbr->select('module_deps', array('md_module', 'md_deps'), array('md_module' => $moduleNames, 'md_skin' => $vary), __METHOD__);
// Prime in-object cache for file dependencies
$modulesWithDeps = array();
foreach ($res as $row) {
$module = $this->getModule($row->md_module);
if ($module) {
$module->setFileDependencies($context, ResourceLoaderModule::expandRelativePaths(FormatJson::decode($row->md_deps, true)));
$modulesWithDeps[] = $row->md_module;
}
}
// Register the absence of a dependency row too
foreach (array_diff($moduleNames, $modulesWithDeps) as $name) {
$module = $this->getModule($name);
if ($module) {
$this->getModule($name)->setFileDependencies($context, array());
}
}
// Prime in-object cache for message blobs for modules with messages
$modules = array();
foreach ($moduleNames as $name) {
$module = $this->getModule($name);
if ($module && $module->getMessages()) {
$modules[$name] = $module;
}
}
$store = $this->getMessageBlobStore();
$blobs = $store->getBlobs($modules, $lang);
foreach ($blobs as $name => $blob) {
$modules[$name]->setMessageBlob($blob, $lang);
}
}