Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2890288
PhabricatorPhurlURLAliasTransaction.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
PhabricatorPhurlURLAliasTransaction.php
View Options
<?php
final
class
PhabricatorPhurlURLAliasTransaction
extends
PhabricatorPhurlURLTransactionType
{
const
TRANSACTIONTYPE
=
'phurl.alias'
;
public
function
generateOldValue
(
$object
)
{
return
$object
->
getAlias
(
)
;
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setAlias
(
$value
)
;
}
public
function
getTitle
(
)
{
return
pht
(
'%s changed the alias from %s to %s.'
,
$this
->
renderAuthor
(
)
,
$this
->
renderOldValue
(
)
,
$this
->
renderNewValue
(
)
)
;
}
public
function
getTitleForFeed
(
)
{
return
pht
(
'%s changed the alias of %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
->
getAlias
(
)
,
$xactions
)
)
{
$errors
[
]
=
$this
->
newRequiredError
(
pht
(
'Phurls must have an alias.'
)
)
;
}
$max_length
=
$object
->
getColumnMaximumByteLength
(
'alias'
)
;
foreach
(
$xactions
as
$xaction
)
{
$new_alias
=
$xaction
->
getNewValue
(
)
;
// Check length
$new_length
=
strlen
(
$new_alias
)
;
if
(
$new_length
>
$max_length
)
{
$errors
[
]
=
$this
->
newRequiredError
(
pht
(
'The alias can be no longer than %d characters.'
,
$max_length
)
)
;
}
// Check characters
if
(
$xaction
->
getOldValue
(
)
!=
$xaction
->
getNewValue
(
)
)
{
$debug_alias
=
new
PHUIInvisibleCharacterView
(
$new_alias
)
;
if
(
!
preg_match
(
'/[a-zA-Z]/'
,
$new_alias
)
)
{
$errors
[
]
=
$this
->
newRequiredError
(
pht
(
'The alias you provided (%s) must contain at least one '
.
'letter.'
,
$debug_alias
)
)
;
}
if
(
preg_match
(
'/[^a-z0-9]/i'
,
$new_alias
)
)
{
$errors
[
]
=
$this
->
newRequiredError
(
pht
(
'The alias you provided (%s) may only contain letters and '
.
'numbers.'
,
$debug_alias
)
)
;
}
}
}
return
$errors
;
}
public
function
getIcon
(
)
{
return
'fa-compress'
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 13:19 (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1125009
Default Alt Text
PhabricatorPhurlURLAliasTransaction.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment