mirror of https://github.com/hauke68/Magallanes
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.2 KiB
55 lines
1.2 KiB
9 years ago
|
<?php
|
||
|
/*
|
||
|
* This file is part of the Magallanes package.
|
||
|
*
|
||
|
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||
|
*
|
||
|
* For the full copyright and license information, please view the LICENSE
|
||
|
* file that was distributed with this source code.
|
||
|
*/
|
||
|
|
||
|
namespace Mage\Task\BuiltIn\FS;
|
||
|
|
||
|
use Symfony\Component\Process\Process;
|
||
9 years ago
|
use Exception;
|
||
9 years ago
|
|
||
|
/**
|
||
|
* File System Task - Move a File
|
||
|
*
|
||
|
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||
|
*/
|
||
|
class MoveTask extends AbstractFileTask
|
||
|
{
|
||
|
public function getName()
|
||
|
{
|
||
|
return 'fs/move';
|
||
|
}
|
||
|
|
||
|
public function getDescription()
|
||
|
{
|
||
9 years ago
|
try {
|
||
|
return sprintf('[FS] Move "%s" to "%s"', $this->getFile('from'), $this->getFile('to'));
|
||
|
} catch (Exception $exception) {
|
||
|
return '[FS] Move [missing parameters]';
|
||
|
}
|
||
9 years ago
|
}
|
||
|
|
||
|
public function execute()
|
||
|
{
|
||
9 years ago
|
$moveFrom = $this->getFile('from');
|
||
|
$moveTo = $this->getFile('to');
|
||
9 years ago
|
|
||
9 years ago
|
$cmd = sprintf('mv %s %s', $moveFrom, $moveTo);
|
||
9 years ago
|
|
||
|
/** @var Process $process */
|
||
|
$process = $this->runtime->runCommand($cmd);
|
||
|
|
||
|
return $process->isSuccessful();
|
||
|
}
|
||
|
|
||
|
protected function getParameters()
|
||
|
{
|
||
|
return ['from', 'to'];
|
||
|
}
|
||
|
}
|