Path: blob/master/src/infrastructure/markup/rule/PhabricatorConfigRemarkupRule.php
12241 views
<?php12final class PhabricatorConfigRemarkupRule3extends PhutilRemarkupRule {45public function apply($text) {6return preg_replace_callback(7'(@{config:([^}]+)})',8array($this, 'markupConfig'),9$text);10}1112public function getPriority() {13// We're reusing the Diviner atom syntax, so make sure we evaluate before14// the Diviner rule evaluates.15return id(new DivinerSymbolRemarkupRule())->getPriority() - 1;16}1718public function markupConfig(array $matches) {19if (!$this->isFlatText($matches[0])) {20return $matches[0];21}2223$config_key = $matches[1];2425try {26$option = PhabricatorEnv::getEnvConfig($config_key);27} catch (Exception $ex) {28return $matches[0];29}3031$is_text = $this->getEngine()->isTextMode();32$is_html_mail = $this->getEngine()->isHTMLMailMode();3334if ($is_text || $is_html_mail) {35return pht('"%s"', $config_key);36}3738$link = phutil_tag(39'a',40array(41'href' => urisprintf('/config/edit/%s/', $config_key),42'target' => '_blank',43),44$config_key);4546return $this->getEngine()->storeText($link);47}4849}505152