Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96119043
PhabricatorPhurlURLLongURLTransaction.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
Sun, Dec 22, 20:14
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Dec 24, 20:14 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23126425
Attached To
rPH Phabricator
PhabricatorPhurlURLLongURLTransaction.php
View Options
<?php
final
class
PhabricatorPhurlURLLongURLTransaction
extends
PhabricatorPhurlURLTransactionType
{
const
TRANSACTIONTYPE
=
'phurl.longurl'
;
public
function
generateOldValue
(
$object
)
{
return
$object
->
getLongURL
();
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setLongURL
(
$value
);
}
public
function
getTitle
()
{
return
pht
(
'%s changed the destination URL from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderOldValue
(),
$this
->
renderNewValue
());
}
public
function
getTitleForFeed
()
{
return
pht
(
'%s changed the destination URL %s from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
(),
$this
->
renderOldValue
(),
$this
->
renderNewValue
());
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
if
(
$this
->
isEmptyTextTransaction
(
$object
->
getLongURL
(),
$xactions
))
{
$errors
[]
=
$this
->
newRequiredError
(
pht
(
'URL path is required'
));
}
foreach
(
$xactions
as
$xaction
)
{
if
(
$xaction
->
getOldValue
()
!=
$xaction
->
getNewValue
())
{
$protocols
=
PhabricatorEnv
::
getEnvConfig
(
'uri.allowed-protocols'
);
$uri
=
new
PhutilURI
(
$xaction
->
getNewValue
());
if
(!
isset
(
$protocols
[
$uri
->
getProtocol
()]))
{
$errors
[]
=
$this
->
newRequiredError
(
pht
(
'The protocol of the URL is invalid.'
));
}
}
}
return
$errors
;
}
public
function
getIcon
()
{
return
'fa-external-link-square'
;
}
}
Event Timeline
Log In to Comment