当前位置: 首页>>代码示例>>PHP>>正文


PHP File::replaceText方法代码示例

本文整理汇总了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');
     }
 }
开发者ID:UnionCMS,项目名称:Core,代码行数:29,代码来源:Installer.php

示例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();
 }
开发者ID:Slayug,项目名称:castor,代码行数:29,代码来源:FileTest.php


注:本文中的Cake\Filesystem\File::replaceText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。