當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。