Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2892850
PhabricatorFilesManagementWorkflow.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
PhabricatorFilesManagementWorkflow.php
View Options
<?php
abstract
class
PhabricatorFilesManagementWorkflow
extends
PhabricatorManagementWorkflow
{
protected
function
newIteratorArguments
(
)
{
return
array
(
array
(
'name'
=>
'all'
,
'help'
=>
pht
(
'Operate on all files.'
)
,
)
,
array
(
'name'
=>
'names'
,
'wildcard'
=>
true
,
)
,
array
(
'name'
=>
'from-engine'
,
'param'
=>
'storage-engine'
,
'help'
=>
pht
(
'Operate on files stored in a specified engine.'
)
,
)
,
)
;
}
protected
function
buildIterator
(
PhutilArgumentParser
$args
)
{
$viewer
=
$this
->
getViewer
(
)
;
$is_all
=
$args
->
getArg
(
'all'
)
;
$names
=
$args
->
getArg
(
'names'
)
;
$from_engine
=
$args
->
getArg
(
'from-engine'
)
;
$any_constraint
=
(
$from_engine
||
$names
)
;
if
(
!
$is_all
&&
!
$any_constraint
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Specify which files to operate on, or use "--all" to operate on '
.
'all files.'
)
)
;
}
if
(
$is_all
&&
$any_constraint
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'You can not operate on all files with "--all" and also operate '
.
'on a subset of files by naming them explicitly or using '
.
'constraint flags like "--from-engine".'
)
)
;
}
// If we're migrating specific named files, convert the names into IDs
// first.
$ids
=
null
;
if
(
$names
)
{
$files
=
$this
->
loadFilesWithNames
(
$names
)
;
$ids
=
mpull
(
$files
,
'getID'
)
;
}
$query
=
id
(
new
PhabricatorFileQuery
(
)
)
->
setViewer
(
$viewer
)
;
if
(
$ids
)
{
$query
->
withIDs
(
$ids
)
;
}
if
(
$from_engine
)
{
$query
->
withStorageEngines
(
array
(
$from_engine
)
)
;
}
return
new
PhabricatorQueryIterator
(
$query
)
;
}
protected
function
loadFilesWithNames
(
array
$names
)
{
$query
=
id
(
new
PhabricatorObjectQuery
(
)
)
->
setViewer
(
$this
->
getViewer
(
)
)
->
withNames
(
$names
)
->
withTypes
(
array
(
PhabricatorFileFilePHIDType
::
TYPECONST
)
)
;
$query
->
execute
(
)
;
$files
=
$query
->
getNamedResults
(
)
;
foreach
(
$names
as
$name
)
{
if
(
empty
(
$files
[
$name
]
)
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'No file "%s" exists.'
,
$name
)
)
;
}
}
return
array_values
(
$files
)
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 17:27 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126952
Default Alt Text
PhabricatorFilesManagementWorkflow.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment