2012-10-25 20:36:38 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class PhabricatorFilesManagementWorkflow
|
|
|
|
extends PhutilArgumentWorkflow {
|
|
|
|
|
|
|
|
public function isExecutable() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-05-29 15:28:57 +02:00
|
|
|
protected function buildIterator(PhutilArgumentParser $args) {
|
|
|
|
if ($args->getArg('all')) {
|
|
|
|
if ($args->getArg('names')) {
|
|
|
|
throw new PhutilArgumentUsageException(
|
|
|
|
"Specify either a list of files or `--all`, but not both.");
|
|
|
|
}
|
|
|
|
return new LiskMigrationIterator(new PhabricatorFile());
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($args->getArg('names')) {
|
|
|
|
$iterator = array();
|
|
|
|
|
2013-09-30 18:38:13 +02:00
|
|
|
// TODO: (T603) Convert this to ObjectNameQuery.
|
|
|
|
|
2013-05-29 15:28:57 +02:00
|
|
|
foreach ($args->getArg('names') as $name) {
|
|
|
|
$name = trim($name);
|
|
|
|
|
|
|
|
$id = preg_replace('/^F/i', '', $name);
|
|
|
|
if (ctype_digit($id)) {
|
|
|
|
$file = id(new PhabricatorFile())->loadOneWhere(
|
|
|
|
'id = %d',
|
|
|
|
$id);
|
|
|
|
if (!$file) {
|
|
|
|
throw new PhutilArgumentUsageException(
|
|
|
|
"No file exists with ID '{$name}'.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$file = id(new PhabricatorFile())->loadOneWhere(
|
2013-08-02 20:20:25 +02:00
|
|
|
'phid = %s',
|
2013-05-29 15:28:57 +02:00
|
|
|
$name);
|
|
|
|
if (!$file) {
|
|
|
|
throw new PhutilArgumentUsageException(
|
|
|
|
"No file exists with PHID '{$name}'.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$iterator[] = $file;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $iterator;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-25 20:36:38 +02:00
|
|
|
}
|