Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F435795
PhabricatorConfigRemarkupRule.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorConfigRemarkupRule.php
View Options
<?php
final
class
PhabricatorConfigRemarkupRule
extends
PhutilRemarkupRule
{
public
function
apply
(
$text
)
{
return
preg_replace_callback
(
'(@{config:([^}]+)})'
,
array
(
$this
,
'markupConfig'
),
$text
);
}
public
function
getPriority
()
{
// We're reusing the Diviner atom syntax, so make sure we evaluate before
// the Diviner rule evaluates.
return
id
(
new
DivinerSymbolRemarkupRule
())->
getPriority
()
-
1
;
}
public
function
markupConfig
(
array
$matches
)
{
if
(!
$this
->
isFlatText
(
$matches
[
0
]))
{
return
$matches
[
0
];
}
$config_key
=
$matches
[
1
];
try
{
$option
=
PhabricatorEnv
::
getEnvConfig
(
$config_key
);
}
catch
(
Exception
$ex
)
{
return
$matches
[
0
];
}
$is_text
=
$this
->
getEngine
()->
isTextMode
();
$is_html_mail
=
$this
->
getEngine
()->
isHTMLMailMode
();
if
(
$is_text
||
$is_html_mail
)
{
return
pht
(
'"%s"'
,
$config_key
);
}
$link
=
phutil_tag
(
'a'
,
array
(
'href'
=>
urisprintf
(
'/config/edit/%s/'
,
$config_key
),
'target'
=>
'_blank'
,
),
$config_key
);
return
$this
->
getEngine
()->
storeText
(
$link
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 3, 9:05 PM (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
57961
Default Alt Text
PhabricatorConfigRemarkupRule.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment