本文整理汇总了PHP中Cake\Filesystem\File::replaceText方法的典型用法代码示例。如果您正苦于以下问题:PHP File::replaceText方法的具体用法?PHP File::replaceText怎么用?PHP File::replaceText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Filesystem\File
的用法示例。
在下文中一共展示了File::replaceText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _reloadDebugKitPlugin
/**
* Reload DebugKit plugin.
*
* @param string $vendorDir
*/
protected static function _reloadDebugKitPlugin($vendorDir)
{
$webRoot = $vendorDir . '/cakephp/debug_kit/webroot';
$assetsDir = $vendorDir . '/cakephp/debug_kit/assets';
if (is_dir($webRoot)) {
// Transport js styles.
$debugWebroot = new Folder($webRoot);
$debugWebroot->copy($assetsDir);
$debugWebroot->delete($webRoot);
}
// Rewrite include scripts.
$debugFilterFile = $vendorDir . '/cakephp/debug_kit/src/Routing/Filter/DebugBarFilter.php';
if (file_exists($debugFilterFile)) {
$debugFilter = new File($debugFilterFile);
$debugFilter->replaceText("Router::url('/debug_kit/js/toolbar.js')", "vPath()->url('DebugKit:assets/js/toolbar.js')");
}
// Reload default DebugKit AjaxView.
$debugViewFile = $vendorDir . '/cakephp/debug_kit/src/View/AjaxView.php';
if (file_exists($debugViewFile)) {
$debugView = new File($debugViewFile);
$debugView->replaceText('use Cake\\View\\View;', '');
$debugView->replaceText('extends View', 'extends \\Union\\App\\View\\AjaxView');
}
}
示例2: testReplaceText
/**
* testReplaceText method
*
* @return void
*/
public function testReplaceText()
{
$TestFile = new File(TEST_APP . 'vendor/welcome.php');
$TmpFile = new File(TMP . 'tests' . DS . 'cakephp.file.test.tmp');
// Copy the test file to the temporary location
$TestFile->copy($TmpFile->path, true);
// Replace the contents of the temporary file
$result = $TmpFile->replaceText('welcome.php', 'welcome.tmp');
$this->assertTrue($result);
// Double check
$expected = 'This is the welcome.tmp file in vendors directory';
$contents = $TmpFile->read();
$this->assertContains($expected, $contents);
$search = ['This is the', 'welcome.php file', 'in tmp directory'];
$replace = ['This should be a', 'welcome.tmp file', 'in the Lib directory'];
// Replace the contents of the temporary file
$result = $TmpFile->replaceText($search, $replace);
$this->assertTrue($result);
// Double check
$expected = 'This should be a welcome.tmp file in vendors directory';
$contents = $TmpFile->read();
$this->assertContains($expected, $contents);
$TmpFile->delete();
}