本文整理汇总了PHP中Cake\Filesystem\Folder::copy方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::copy方法的具体用法?PHP Folder::copy怎么用?PHP Folder::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Filesystem\Folder
的用法示例。
在下文中一共展示了Folder::copy方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPostAutoloadDump
/**
* Test composer post autoload dump event.
*
* @return void
*/
public function testPostAutoloadDump()
{
Plugin::load('DebugKit');
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
if (!defined('TMP')) {
define('TMP', sys_get_temp_dir() . DS);
}
$vendorDir = ROOT . 'vendor';
$webRoot = $vendorDir . '/cakephp/debug_kit/webroot';
$assetsDir = $vendorDir . '/cakephp/debug_kit/assets';
if (!is_dir($webRoot) && is_dir($assetsDir)) {
$debugWebroot = new Folder($assetsDir);
$debugWebroot->copy($webRoot);
$debugWebroot->delete($assetsDir);
}
$composer = new Composer();
/** @var Config $config */
$config = new Config();
$config->merge(['config' => ['vendor-dir' => $vendorDir]]);
$composer->setConfig($config);
/** @var IOInterface $io */
$io = $this->getMock('Composer\\IO\\IOInterface');
$event = new Event('postAutoloadDump', $composer, $io);
Installer::postAutoloadDump($event);
Plugin::unload('DebugKit');
}
示例2: _publish
protected function _publish($option)
{
$folderElement = new Folder(Plugin::path('TwitterBootstrap') . DS . 'src' . DS . 'Template' . DS . 'Element');
switch ($option) {
case 'all':
$folderElement->copy(APP . 'Template' . DS . 'Element', false);
break;
}
$this->out('Arquivos publicados');
}
示例3: installTheme
public function installTheme($theme)
{
if (!Plugin::loaded($theme)) {
throw new \Exception('Plugin não foi carregado.');
}
if (!file_exists(WWW_ROOT . 'theme' . DS . $theme) or Configure::read('debug')) {
$handler = new Folder();
$handler->copy(['to' => WWW_ROOT . 'theme' . DS . $theme, 'from' => Plugin::path($theme) . 'webroot' . DS . '_assets', 'mode' => 0755, 'scheme' => Folder::OVERWRITE]);
return true;
}
return false;
}
示例4: _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');
}
}
示例5: _copyPackage
/**
* Copies the extracted package to its final destination.
*
* @param bool $clearDestination Set to true to delete the destination directory
* if already exists. Defaults to false; an error will occur if destination
* already exists. Useful for upgrade tasks
* @return bool True on success
*/
protected function _copyPackage($clearDestination = false)
{
$source = new Folder($this->_workingDir);
$destinationPath = normalizePath(ROOT . "/plugins/{$this->_plugin['name']}/");
// allow to install from destination folder
if ($this->_workingDir === $destinationPath) {
return true;
}
if (!$clearDestination && is_readable($destinationPath)) {
$this->err(__d('installer', 'Destination directory already exists, please delete manually this directory: {0}', $destinationPath));
return false;
} elseif ($clearDestination && is_readable($destinationPath)) {
$destination = new Folder($destinationPath);
if (!$destination->delete()) {
$this->err(__d('installer', 'Destination directory could not be cleared, please check write permissions: {0}', $destinationPath));
return false;
}
}
if ($source->copy(['to' => $destinationPath])) {
return true;
}
$this->err(__d('installer', 'Error when moving package content.'));
return false;
}
示例6: _copyDirectory
/**
* Copy directory
*
* @param string $source Source directory
* @param string $destination Destination directory
* @return bool
*/
protected function _copyDirectory($source, $destination)
{
$folder = new Folder($source);
if ($folder->copy(['to' => $destination])) {
$this->out('Copied assets to directory ' . $destination);
return true;
}
$this->err('Error copying assets to directory ' . $destination);
return false;
}
示例7: dumpStaticFiles
/**
* Dump static files
*
* @param DOMDocument $domDocument
*
* @throws \Exception
*/
protected function dumpStaticFiles(DOMDocument $domDocument)
{
$xpath = new DOMXPath($domDocument);
$assetsNodeList = $xpath->query('/assetic/static/files/file');
$validFlags = ['GLOB_MARK' => GLOB_MARK, 'GLOB_NOSORT' => GLOB_NOSORT, 'GLOB_NOCHECK' => GLOB_NOCHECK, 'GLOB_NOESCAPE' => GLOB_NOESCAPE, 'GLOB_BRACE' => GLOB_BRACE, 'GLOB_ONLYDIR' => GLOB_ONLYDIR, 'GLOB_ERR' => GLOB_ERR];
/** @var $assetNode DOMElement */
foreach ($assetsNodeList as $assetNode) {
$source = strtr($assetNode->getElementsByTagName('source')->item(0)->nodeValue, $this->paths);
$destination = strtr($assetNode->getElementsByTagName('destination')->item(0)->nodeValue, $this->paths);
$flag = $assetNode->getElementsByTagName('source')->item(0)->getAttribute('flag');
if (empty($flag)) {
$flag = null;
} else {
if (!array_key_exists($flag, $validFlags)) {
throw new \Exception(sprintf('This flag "%s" not valid.', $flag));
}
$flag = $validFlags[$flag];
}
$des = new Folder(WWW_ROOT . $destination, true, 0777);
$allFiles = glob($source, $flag);
foreach ($allFiles as $src) {
if (is_dir($src)) {
$srcFolder = new Folder($src);
$srcFolder->copy($des->pwd());
} else {
$srcFile = new File($src);
$srcFile->copy($des->path . DS . $srcFile->name);
}
$this->out($src . ' <info> >>> </info> ' . WWW_ROOT . $destination);
}
}
}
示例8: postUpdate
/**
* Does some routine installation tasks so people don't have to.
*
* @param \Composer\Script\Event $event The composer event object.
* @throws \Exception Exception raised by validator.
* @return void
*/
public static function postUpdate(Event $event)
{
$io = $event->getIO();
$rootDir = dirname(dirname(__DIR__));
$jqueryVendorDir = $rootDir . '/vendor/components/jquery';
$jqueryWebrootDir = $rootDir . '/webroot/js/vendor/jquery';
$foundationVendorDir = $rootDir . '/vendor/zurb/foundation/js/foundation';
$foundationWebrootDir = $rootDir . '/webroot/js/vendor/foundation';
$modernizrVendorDir = $rootDir . '/vendor/components/modernizr';
$modernizrWebrootDir = $rootDir . '/webroot/js/vendor/modernizr';
if (is_dir($jqueryVendorDir)) {
$jqueryFolder = new Folder($jqueryVendorDir);
$jqueryFolder->copy($jqueryWebrootDir);
$io->write('Copied `Jquery` files');
}
if (is_dir($foundationVendorDir)) {
$foundationFolder = new Folder($foundationVendorDir);
$foundationFolder->copy($foundationWebrootDir);
$io->write('Copied `Zurb Foundation JS` files');
}
if (is_dir($modernizrVendorDir)) {
$modernizrFolder = new Folder($modernizrVendorDir);
$modernizrFolder->copy($modernizrWebrootDir);
$io->write('Copied `Modernizr` files');
}
}
示例9: sync
public function sync($id = null)
{
$folder = new Folder();
$folders_to_copy = ['f1' => ['dev' => '../src', 'prod' => '../../production/src'], 'f2' => ['dev' => '../plugins', 'prod' => '../../production/plugins'], 'f3' => ['dev' => '../webroot', 'prod' => '../../production/webroot'], 'f4' => ['dev' => '../config', 'prod' => '../../production/config']];
$pass = 0;
$fail = 0;
foreach ($folders_to_copy as $ftc) {
$p = new Folder($ftc['prod']);
$d = new Folder($ftc['dev']);
if ($folder->copy(['to' => $p->pwd(), 'from' => $d->pwd(), 'scheme' => Folder::MERGE])) {
$pass++;
} else {
$fail++;
}
}
if ($fail == 0) {
$this->Flash->success(__('Production updated successfully.'));
} else {
$errors = '';
foreach ($folder->errors() as $error) {
$errors .= ' : ' . $error;
}
$this->Flash->error(__('Unable to update {0} folders on production. Errors' . $errors, $fail));
}
return $this->redirect($this->referer());
}
示例10: testCopyWithoutRecursive
/**
* testCopyWithoutResursive
*
* Verify that only the files exist in the target directory.
*
* @return void
*/
public function testCopyWithoutRecursive()
{
extract($this->_setupFilesystem());
$Folder = new Folder($folderOne);
$result = $Folder->copy(['to' => $folderThree, 'recursive' => false]);
$this->assertTrue(file_exists($folderThree . DS . 'file1.php'));
$this->assertFalse(is_dir($folderThree . DS . 'folderA'));
$this->assertFalse(file_exists($folderThree . DS . 'folderA' . DS . 'fileA.php'));
}
示例11: testCopyWithOverwrite
/**
* testCopyWithOverwrite
*
* Verify that subdirectories existing in both destination and source directory
* are overwritten/replaced recursively.
*
* @return void
*/
public function testCopyWithOverwrite()
{
extract($this->_setupFilesystem());
$Folder = new Folder($folderOne);
$result = $Folder->copy(['to' => $folderThree, 'scheme' => Folder::OVERWRITE]);
$this->assertTrue(file_exists($folderThree . DS . 'file1.php'));
$this->assertTrue(file_exists($folderThree . DS . 'folderA' . DS . 'fileA.php'));
$Folder = new Folder($folderTwo);
$result = $Folder->copy(['to' => $folderThree, 'scheme' => Folder::OVERWRITE]);
$this->assertTrue($result);
$this->assertTrue(file_exists($folderThree . DS . 'folderA' . DS . 'fileA.php'));
$Folder = new Folder($folderOne);
unlink($fileOneA);
$result = $Folder->copy(['to' => $folderThree, 'scheme' => Folder::OVERWRITE]);
$this->assertTrue($result);
$this->assertTrue(file_exists($folderThree . DS . 'file1.php'));
$this->assertTrue(file_exists($folderThree . DS . 'file2.php'));
$this->assertTrue(!file_exists($folderThree . DS . 'folderA' . DS . 'fileA.php'));
$this->assertTrue(file_exists($folderThree . DS . 'folderB' . DS . 'fileB.php'));
}