本文整理汇总了PHP中Composer\Util\Filesystem::copyThenRemove方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::copyThenRemove方法的具体用法?PHP Filesystem::copyThenRemove怎么用?PHP Filesystem::copyThenRemove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Util\Filesystem
的用法示例。
在下文中一共展示了Filesystem::copyThenRemove方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: movePersistentDirectories
protected function movePersistentDirectories($sourceDir, $targetDir)
{
foreach ($this->persistentDirs as $dir) {
$source = $sourceDir . self::DS . $dir;
$target = $targetDir . self::DS . $dir;
if (file_exists($source)) {
$this->emptyDir($target);
$this->fs->copyThenRemove($source, $target);
}
}
}
示例2: complete
/**
* Complete the setup task.
*
* @since 0.1.0
*
* @return void
*/
public function complete()
{
$filesystem = new Filesystem();
$templatesFolder = $this->getConfigKey('Folders', 'templates');
$finder = new Finder();
foreach ($finder->files()->in($templatesFolder) as $file) {
$from = $file->getPathname();
$to = $this->getTargetPath($from);
$filesystem->ensureDirectoryExists(dirname($to));
$filesystem->copyThenRemove($from, $to);
}
}
示例3: installRubedoCoreSources
/**
* Install Rubedo Core sources
*
* @param string $actualRootDir Rubedo root dir for project
* @param array $removedFiles List of old files to remove after installation
*/
protected function installRubedoCoreSources($actualRootDir, $removedFiles)
{
if ($this->io->isVerbose()) {
$this->io->write("Updating new code over existing installation.");
}
// Removing files / directories to ignore from installation from temporary dir
$this->cleanTempDir();
$this->fileSystem->copyThenRemove($this->rubedoRootDir, $actualRootDir);
$this->rubedoRootDir = $actualRootDir;
// Deleting files removed from the previous package release
$this->deleteRemovedFiles($removedFiles);
}
示例4: complete
/**
* Renames the plugin file to {{package}}.php,
* removes it, if the package is not of type wordpress-plugin
*/
public function complete()
{
$fs = new Util\Filesystem();
$base_dir = $this->getConfigKey('BaseDir');
$type = $this->getConfigKey('Placeholders', 'type')['value'];
$package = $this->getConfigKey('Placeholders', 'package_key')['value'];
$plugin_file = "{$base_dir}/plugin.php";
if ('wordpress-plugin' === $type) {
$fs->copyThenRemove($plugin_file, "{$base_dir}/{$package}.php");
return;
}
$this->io->write("Removing plugin file");
$fs->remove($plugin_file);
}
示例5: complete
/**
* Renames the relevant license file to 'LICENSE' and removes
* the one we don't use
*/
public function complete()
{
$fs = new Util\Filesystem();
$base_dir = $this->getConfigKey('BaseDir');
$license = $this->getConfigKey('Placeholders', 'license')['value'];
$license_files = ['MIT' => 'LICENSE.mit', 'GPL-2.0' => 'LICENSE.gpl2'];
if (!isset($license_files[$license])) {
throw new Exception\LogicException("No file found for license '{$license}'");
}
$license_file = "{$base_dir}/{$license_files[$license]}";
$fs->copyThenRemove($license_file, "{$base_dir}/LICENSE");
foreach ($license_files as $file) {
$this->io->write(sprintf("Removing license file %s", basename($file)));
$fs->remove($file);
}
}
示例6: install
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
$downloadPath = $this->getInstallPath($package);
$fileSystem = new Filesystem();
$actualLegacyDir = $this->innomaticLegacyDir;
$this->innomaticLegacyDir = $this->generateTempDirName();
if (!is_dir($downloadPath) || $fileSystem->isDirEmpty($downloadPath)) {
if ($this->io->isVerbose()) {
$this->io->write("Installing in temporary directory.");
}
parent::install($repo, $package);
if ($this->io->isVerbose()) {
$this->io->write("Copying to the Innomatic legacy directory.");
}
$fileSystem->copyThenRemove($this->innomaticLegacyDir . '/source/', $actualLegacyDir);
$this->innomaticLegacyDir = $actualLegacyDir;
}
}
示例7: updateCode
/**
* Same as install(): we need to insure there is no removal of actual eZ code.
* updateCode is called by update()
*/
public function updateCode( PackageInterface $initial, PackageInterface $target )
{
$actualLegacyDir = $this->ezpublishLegacyDir;
$this->ezpublishLegacyDir = $this->generateTempDirName();
if ( $this->io->isVerbose() )
{
$this->io->write( "Installing in temporary directory." );
}
$this->installCode( $target );
$fileSystem = new Filesystem();
if ( $this->io->isVerbose() )
{
$this->io->write( "Updating new code over existing installation." );
}
/// @todo the following function does not warn of any failures in copying stuff over. We should probably fix it...
$fileSystem->copyThenRemove( $this->ezpublishLegacyDir, $actualLegacyDir );
$this->ezpublishLegacyDir = $actualLegacyDir;
}
示例8: onPostUpdate
public function onPostUpdate(Event $event)
{
// Load global plugin configuration
$globalCfg = $this->getGlobalConfig();
if ($globalCfg) {
$extra = self::get($globalCfg, 'extra', []);
$myConfig = self::get($extra, self::EXTRA_KEY, []);
if ($myConfig) {
$this->info("Global configuration loaded");
}
} else {
$myConfig = [];
}
// Merge project-specific configuration.
// Ignore it if Composer is running in global mode.
$package = $this->composer->getPackage();
if ($package->getName() != '__root__') {
$projCfg = self::get($package->getExtra(), self::EXTRA_KEY, []);
$myConfig = array_merge_recursive($myConfig, $projCfg);
$this->info("Project-specific configuration loaded");
}
// Setup
$rules = array_unique(self::get($myConfig, self::RULES_KEY, []));
$sharedDir = str_replace('~', getenv('HOME'), self::get($myConfig, self::SHARED_DIR_KEY, self::DEFAULT_SHARED_DIR));
$packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
$rulesInfo = implode(', ', $rules);
$this->info("Shared directory: <info>{$sharedDir}</info>");
$this->info("Match packages: <info>{$rulesInfo}</info>");
$fsUtil = new FilesystemUtil();
$fs = new Filesystem();
// Do useful work
$count = 0;
foreach ($packages as $package) {
$srcDir = $this->getInstallPath($package);
$packageName = $package->getName();
if (self::globMatchAny($rules, $packageName) && !$fsUtil->isSymlinkedDirectory($srcDir)) {
$destPath = "{$sharedDir}/{$packageName}";
if (!file_exists($destPath)) {
$fsUtil->copyThenRemove($srcDir, $destPath);
$this->info("Moved <info>{$packageName}</info> to shared directory and symlinked to it");
} else {
$fs->remove($srcDir);
$this->info("Symlinked to existing <info>{$packageName}</info> on shared directory");
}
$fs->symlink($destPath, $srcDir);
++$count;
}
}
if (!$count) {
$this->info("No packages matched");
}
}