VersionPress\Utils\FileSystem::copy PHP Method

copy() public static method

Copies a file. Uses Symfony's copy but actually honors the third parameter.
public static copy ( string $origin, string $target, boolean $override = false )
$origin string
$target string
$override boolean
    public static function copy($origin, $target, $override = false)
    {
        $fs = new \Symfony\Component\Filesystem\Filesystem();
        if (!$override && $fs->exists($target)) {
            return;
        }
        $fs->copy($origin, $target, $override);
    }

Usage Example

 public function saveDefinitionForPlugin($pluginFile)
 {
     $pluginSlug = basename(dirname($pluginFile));
     $actionsFile = WP_PLUGIN_DIR . '/' . $pluginSlug . '/.versionpress/actions.yml';
     if (!is_file($actionsFile)) {
         return;
     }
     $targetFile = $this->getDefinitionFileName($pluginSlug);
     FileSystem::copy($actionsFile, $targetFile);
 }
All Usage Examples Of VersionPress\Utils\FileSystem::copy