Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F570295
PhabricatorPeopleMailEngine.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
PhabricatorPeopleMailEngine.php
View Options
<?php
abstract
class
PhabricatorPeopleMailEngine
extends
Phobject
{
private
$sender
;
private
$recipient
;
private
$recipientAddress
;
private
$activityLog
;
final
public
function
setSender
(
PhabricatorUser
$sender
)
{
$this
->
sender
=
$sender
;
return
$this
;
}
final
public
function
getSender
()
{
if
(!
$this
->
sender
)
{
throw
new
PhutilInvalidStateException
(
'setSender'
);
}
return
$this
->
sender
;
}
final
public
function
setRecipient
(
PhabricatorUser
$recipient
)
{
$this
->
recipient
=
$recipient
;
return
$this
;
}
final
public
function
getRecipient
()
{
if
(!
$this
->
recipient
)
{
throw
new
PhutilInvalidStateException
(
'setRecipient'
);
}
return
$this
->
recipient
;
}
final
public
function
setRecipientAddress
(
PhutilEmailAddress
$address
)
{
$this
->
recipientAddress
=
$address
;
return
$this
;
}
final
public
function
getRecipientAddress
()
{
if
(!
$this
->
recipientAddress
)
{
throw
new
PhutilInvalidStateException
(
'recipientAddress'
);
}
return
$this
->
recipientAddress
;
}
final
public
function
hasRecipientAddress
()
{
return
(
$this
->
recipientAddress
!==
null
);
}
final
public
function
setActivityLog
(
PhabricatorUserLog
$activity_log
)
{
$this
->
activityLog
=
$activity_log
;
return
$this
;
}
final
public
function
getActivityLog
()
{
return
$this
->
activityLog
;
}
final
public
function
canSendMail
()
{
try
{
$this
->
validateMail
();
return
true
;
}
catch
(
PhabricatorPeopleMailEngineException
$ex
)
{
return
false
;
}
}
final
public
function
sendMail
()
{
$this
->
validateMail
();
$mail
=
$this
->
newMail
();
if
(
$this
->
hasRecipientAddress
())
{
$recipient_address
=
$this
->
getRecipientAddress
();
$mail
->
addRawTos
(
array
(
$recipient_address
->
getAddress
()));
}
else
{
$recipient
=
$this
->
getRecipient
();
$mail
->
addTos
(
array
(
$recipient
->
getPHID
()));
}
$activity_log
=
$this
->
getActivityLog
();
if
(
$activity_log
)
{
$activity_log
->
save
();
$body
=
array
();
$body
[]
=
rtrim
(
$mail
->
getBody
(),
"
\n
"
);
$body
[]
=
pht
(
'Activity Log ID: #%d'
,
$activity_log
->
getID
());
$body
=
implode
(
"
\n\n
"
,
$body
).
"
\n
"
;
$mail
->
setBody
(
$body
);
}
$mail
->
setForceDelivery
(
true
)
->
save
();
return
$mail
;
}
abstract
public
function
validateMail
();
abstract
protected
function
newMail
();
final
protected
function
throwValidationException
(
$title
,
$body
)
{
throw
new
PhabricatorPeopleMailEngineException
(
$title
,
$body
);
}
final
protected
function
newRemarkupText
(
$text
)
{
$recipient
=
$this
->
getRecipient
();
$engine
=
PhabricatorMarkupEngine
::
newMarkupEngine
(
array
())
->
setConfig
(
'viewer'
,
$recipient
)
->
setConfig
(
'uri.base'
,
PhabricatorEnv
::
getProductionURI
(
'/'
))
->
setMode
(
PhutilRemarkupEngine
::
MODE_TEXT
);
$rendered_text
=
$engine
->
markupText
(
$text
);
$rendered_text
=
rtrim
(
$rendered_text
,
"
\n
"
);
return
$rendered_text
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, May 13, 3:22 PM (1 d, 23 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
115879
Default Alt Text
PhabricatorPeopleMailEngine.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment