2012-10-25 20:36:38 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class PhabricatorFilesManagementWorkflow
|
2013-12-27 22:15:40 +01:00
|
|
|
extends PhabricatorManagementWorkflow {
|
2012-10-25 20:36:38 +02:00
|
|
|
|
2013-05-29 15:28:57 +02:00
|
|
|
protected function buildIterator(PhutilArgumentParser $args) {
|
2013-09-30 21:23:18 +02:00
|
|
|
$names = $args->getArg('names');
|
|
|
|
|
2013-05-29 15:28:57 +02:00
|
|
|
if ($args->getArg('all')) {
|
2013-09-30 21:23:18 +02:00
|
|
|
if ($names) {
|
2013-05-29 15:28:57 +02:00
|
|
|
throw new PhutilArgumentUsageException(
|
|
|
|
"Specify either a list of files or `--all`, but not both.");
|
|
|
|
}
|
|
|
|
return new LiskMigrationIterator(new PhabricatorFile());
|
|
|
|
}
|
|
|
|
|
2013-09-30 21:23:18 +02:00
|
|
|
if ($names) {
|
|
|
|
$query = id(new PhabricatorObjectQuery())
|
2013-12-27 22:15:40 +01:00
|
|
|
->setViewer($this->getViewer())
|
2013-09-30 21:23:18 +02:00
|
|
|
->withNames($names)
|
|
|
|
->withTypes(array(PhabricatorFilePHIDTypeFile::TYPECONST));
|
|
|
|
|
|
|
|
$query->execute();
|
|
|
|
$files = $query->getNamedResults();
|
|
|
|
|
|
|
|
foreach ($names as $name) {
|
|
|
|
if (empty($files[$name])) {
|
|
|
|
throw new PhutilArgumentUsageException(
|
|
|
|
"No file '{$name}' exists!");
|
2013-05-29 15:28:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-30 21:23:18 +02:00
|
|
|
return array_values($files);
|
2013-05-29 15:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-25 20:36:38 +02:00
|
|
|
}
|