本文整理汇总了PHP中ResourceLoader::respond方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceLoader::respond方法的具体用法?PHP ResourceLoader::respond怎么用?PHP ResourceLoader::respond使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResourceLoader
的用法示例。
在下文中一共展示了ResourceLoader::respond方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testResourceLoaderModifyMaxAge
/**
* @group Slow
* @slowExecutionTime 0.01651 ms
* @dataProvider resourceLoaderModifyMaxAgeDataProvider
*
* @param $timestamp int timestamp in URL
* @param $ttl int expected caching period
*/
public function testResourceLoaderModifyMaxAge($version, $ttl)
{
global $wgHooks;
$resourceLoader = new ResourceLoader();
$resourceLoader->register('WikiaTestModule', array('class' => 'TestResourceLoaderModule'));
$request = new WebRequest();
$request->setVal('modules', 'WikiaTestModule');
$request->setVal('version', join('-', $version));
// set up hooks
$wgHooks['ResourceLoaderCacheControlHeaders'][] = 'ResourceLoaderTest::onResourceLoaderCacheControlHeaders';
ob_start();
$resourceLoader->respond(new ResourceLoaderContext($resourceLoader, $request));
ob_end_clean();
// hook ResourceLoaderHooks::onResourceLoaderModifyMaxAge was called
// check modified caching period with expected one
$this->assertEquals($ttl, self::$ttl, 'TTL should match expected value');
}
示例2: ResourceLoader
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
* @author Roan Kattouw
* @author Trevor Parscal
*/
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
// This endpoint is supposed to be independent of request cookies and other
// details of the session. Enforce this constraint with respect to session use.
define('MW_NO_SESSION', 1);
require __DIR__ . '/includes/WebStart.php';
// URL safety checks
if (!$wgRequest->checkUrlExtension()) {
return;
}
// Don't initialise ChronologyProtector from object cache, and
// don't wait for unrelated MediaWiki writes when querying ResourceLoader.
MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo(['ChronologyProtection' => 'false']);
// Set up ResourceLoader
$resourceLoader = new ResourceLoader(ConfigFactory::getDefaultInstance()->makeConfig('main'), LoggerFactory::getInstance('resourceloader'));
$context = new ResourceLoaderContext($resourceLoader, $wgRequest);
// Respond to ResourceLoader request
$resourceLoader->respond($context);
Profiler::instance()->setTemplated(true);
$mediawiki = new MediaWiki();
$mediawiki->doPostOutputShutdown('fast');
示例3: dirname
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
* @author Roan Kattouw
* @author Trevor Parscal
*/
use MediaWiki\Logger\LoggerFactory;
// Bail on old versions of PHP, or if composer has not been run yet to install
// dependencies. Using dirname( __FILE__ ) here because __DIR__ is PHP5.3+.
require_once dirname(__FILE__) . '/includes/PHPVersionCheck.php';
wfEntryPointCheck('load.php');
require __DIR__ . '/includes/WebStart.php';
// URL safety checks
if (!$wgRequest->checkUrlExtension()) {
return;
}
// Respond to resource loading request.
// foo()->bar() syntax is not supported in PHP4, and this file needs to *parse* in PHP4.
$configFactory = ConfigFactory::getDefaultInstance();
$resourceLoader = new ResourceLoader($configFactory->makeConfig('main'), LoggerFactory::getInstance('resourceloader'));
$resourceLoader->respond(new ResourceLoaderContext($resourceLoader, $wgRequest));
Profiler::instance()->setTemplated(true);
$mediawiki = new MediaWiki();
$mediawiki->doPostOutputShutdown('fast');