本文整理汇总了PHP中Requirements::get_combine_files方法的典型用法代码示例。如果您正苦于以下问题:PHP Requirements::get_combine_files方法的具体用法?PHP Requirements::get_combine_files怎么用?PHP Requirements::get_combine_files使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Requirements
的用法示例。
在下文中一共展示了Requirements::get_combine_files方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBlockedCombinedJavascript
function testBlockedCombinedJavascript()
{
$combinedFilePath = Director::baseFolder() . '/' . 'RequirementsTest_bc.js';
/* BLOCKED COMBINED FILES ARE NOT INCLUDED */
$this->setupCombinedRequirements();
Requirements::block('RequirementsTest_bc.js');
Requirements::delete_combined_files('RequirementsTest_bc.js');
clearstatcache();
// needed to get accurate file_exists() results
$html = Requirements::includeInHTML(false, self::$html_template);
$this->assertFalse((bool) preg_match('/src=".*\\/RequirementsTest_bc\\.js/', $html), 'blocked combined files are not included ');
Requirements::unblock('RequirementsTest_bc.js');
/* BLOCKED UNCOMBINED FILES ARE NOT INCLUDED */
// need to re-add requirements, as Requirements::process_combined_includes() alters the
// original arrays grml...
$this->setupCombinedRequirements();
Requirements::block('sapphire/tests/forms/RequirementsTest_b.js');
Requirements::delete_combined_files('RequirementsTest_bc.js');
clearstatcache();
// needed to get accurate file_exists() results
$html = Requirements::includeInHTML(false, self::$html_template);
$this->assertFalse(strpos(file_get_contents($combinedFilePath), "alert('b')") !== false, 'blocked uncombined files are not included');
Requirements::unblock('RequirementsTest_b.js');
/* A SINGLE FILE CAN'T BE INCLUDED IN TWO COMBINED FILES */
$this->setupCombinedRequirements();
clearstatcache();
// needed to get accurate file_exists() results
// This throws a notice-level error, so we prefix with @
@Requirements::combine_files('RequirementsTest_ac.js', array('sapphire/tests/forms/RequirementsTest_a.js', 'sapphire/tests/forms/RequirementsTest_c.js'));
$combinedFiles = Requirements::get_combine_files();
$this->assertEquals(array_keys($combinedFiles), array('RequirementsTest_bc.js'), "A single file can't be included in two combined files");
Requirements::delete_combined_files('RequirementsTest_bc.js');
}
示例2: CombineThemeRelativeFile
public static function CombineThemeRelativeFile($combine_name, $pathrelativetotheme, $makeFirstItem = false)
{
$themedir = SSViewer::current_theme();
$file = "themes/{$themedir}/{$pathrelativetotheme}";
$to_combine = array($file);
$combine_name = "{$themedir}-{$combine_name}";
$previously_included = Requirements::get_combine_files();
// append to existing array, if any
if (array_key_exists($combine_name, $previously_included)) {
if ($makeFirstItem) {
$to_combine = array_merge($to_combine, $previously_included[$combine_name]);
} else {
$to_combine = array_merge($previously_included[$combine_name], $to_combine);
}
}
Requirements::combine_files($combine_name, $to_combine);
}
示例3: httpError
/**
* Returns the HTTP error response.
*
* @param string $code Error code
* @param string $message Error message
*
* @return void
*
* @throws SS_HTTPResponse_Exception
* @author Sebastian Diel <sdiel@pixeltricks.de>
* @since 07.05.2015
*/
public function httpError($code, $message = null)
{
$combined_files = Requirements::get_combine_files();
try {
$response = parent::httpError($code, $message);
} catch (SS_HTTPResponse_Exception $e) {
$originalResponse = $e->getResponse();
Requirements::restore();
foreach ($combined_files as $combinedFileName => $files) {
Requirements::combine_files($combinedFileName, $files);
Requirements::process_combined_files();
}
$response = $this->request->isMedia() ? null : self::error_response_for($code);
throw new SS_HTTPResponse_Exception($response ? $response : ($originalResponse ? $originalResponse : $message), $code);
}
}