Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97267933
PhabricatorFileTransform.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Jan 3, 22:16
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Jan 5, 22:16 (2 d)
Engine
blob
Format
Raw Data
Handle
23369956
Attached To
rPH Phabricator
PhabricatorFileTransform.php
View Options
<?php
abstract
class
PhabricatorFileTransform
extends
Phobject
{
abstract
public
function
getTransformName
();
abstract
public
function
getTransformKey
();
abstract
public
function
canApplyTransform
(
PhabricatorFile
$file
);
abstract
public
function
applyTransform
(
PhabricatorFile
$file
);
public
function
getDefaultTransform
(
PhabricatorFile
$file
)
{
return
null
;
}
public
function
generateTransforms
()
{
return
array
(
$this
);
}
public
function
executeTransform
(
PhabricatorFile
$file
)
{
if
(
$this
->
canApplyTransform
(
$file
))
{
try
{
return
$this
->
applyTransform
(
$file
);
}
catch
(
Exception
$ex
)
{
// Ignore.
}
}
return
$this
->
getDefaultTransform
(
$file
);
}
public
static
function
getAllTransforms
()
{
return
id
(
new
PhutilClassMapQuery
())
->
setAncestorClass
(
__CLASS__
)
->
setExpandMethod
(
'generateTransforms'
)
->
setUniqueMethod
(
'getTransformKey'
)
->
execute
();
}
public
static
function
getTransformByKey
(
$key
)
{
$all
=
self
::
getAllTransforms
();
$xform
=
idx
(
$all
,
$key
);
if
(!
$xform
)
{
throw
new
Exception
(
pht
(
'No file transform with key "%s" exists.'
,
$key
));
}
return
$xform
;
}
}
Event Timeline
Log In to Comment