Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97578609
PhortuneMerchantInvoiceEmailTransaction.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, Jan 5, 10:20
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Jan 7, 10:20 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23430254
Attached To
rPH Phabricator
PhortuneMerchantInvoiceEmailTransaction.php
View Options
<?php
final
class
PhortuneMerchantInvoiceEmailTransaction
extends
PhortuneMerchantTransactionType
{
const
TRANSACTIONTYPE
=
'merchant:invoiceemail'
;
public
function
generateOldValue
(
$object
)
{
return
$object
->
getInvoiceEmail
();
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setInvoiceEmail
(
$value
);
}
public
function
getTitle
()
{
$old
=
$this
->
getOldValue
();
$new
=
$this
->
getNewValue
();
if
(
strlen
(
$old
)
&&
strlen
(
$new
))
{
return
pht
(
'%s updated the invoice email from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderOldValue
(),
$this
->
renderNewValue
());
}
else
if
(
strlen
(
$old
))
{
return
pht
(
'%s removed the invoice email.'
,
$this
->
renderAuthor
());
}
else
{
return
pht
(
'%s set the invoice email to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderNewValue
());
}
}
public
function
getTitleForFeed
()
{
$old
=
$this
->
getOldValue
();
$new
=
$this
->
getNewValue
();
if
(
strlen
(
$old
)
&&
strlen
(
$new
))
{
return
pht
(
'%s updated %s invoice email from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
(),
$this
->
renderOldValue
(),
$this
->
renderNewValue
());
}
else
if
(
strlen
(
$old
))
{
return
pht
(
'%s removed the invoice email for %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
());
}
else
{
return
pht
(
'%s set the invoice email for %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
(),
$this
->
renderNewValue
());
}
}
public
function
getIcon
()
{
return
'fa-envelope'
;
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
$max_length
=
$object
->
getColumnMaximumByteLength
(
'invoiceEmail'
);
foreach
(
$xactions
as
$xaction
)
{
if
(
strlen
(
$xaction
->
getNewValue
()))
{
$email
=
new
PhutilEmailAddress
(
$xaction
->
getNewValue
());
$domain
=
$email
->
getDomainName
();
if
(!
strlen
(
$domain
))
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'Invoice email "%s" must be a valid email.'
,
$xaction
->
getNewValue
()));
}
$new_value
=
$xaction
->
getNewValue
();
$new_length
=
strlen
(
$new_value
);
if
(
$new_length
>
$max_length
)
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'The email can be no longer than %s characters.'
,
new
PhutilNumber
(
$max_length
)));
}
}
}
return
$errors
;
}
}
Event Timeline
Log In to Comment