Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / paste / remarkup / PhabricatorPasteRemarkupRule.php
blobe8e26249773bca376ebd1d26037e09710b584430
1 <?php
3 final class PhabricatorPasteRemarkupRule extends PhabricatorObjectRemarkupRule {
5 protected function getObjectNamePrefix() {
6 return 'P';
9 protected function loadObjects(array $ids) {
10 $viewer = $this->getEngine()->getConfig('viewer');
12 return id(new PhabricatorPasteQuery())
13 ->setViewer($viewer)
14 ->withIDs($ids)
15 ->needContent(true)
16 ->execute();
20 protected function renderObjectEmbed(
21 $object,
22 PhabricatorObjectHandle $handle,
23 $options) {
25 $embed_paste = id(new PasteEmbedView())
26 ->setPaste($object)
27 ->setHandle($handle);
29 if (strlen($options)) {
30 $parser = new PhutilSimpleOptions();
31 $opts = $parser->parse(substr($options, 1));
33 foreach ($opts as $key => $value) {
34 if ($key == 'lines') {
35 $embed_paste->setLines(preg_replace('/[^0-9]/', '', $value));
36 } else if ($key == 'highlight') {
37 $highlights = preg_split('/,|&/', preg_replace('/\s+/', '', $value));
39 $to_highlight = array();
40 foreach ($highlights as $highlight) {
41 $highlight = explode('-', $highlight);
43 if (!empty($highlight)) {
44 sort($highlight);
45 $to_highlight = array_merge(
46 $to_highlight,
47 range(head($highlight), last($highlight)));
51 $embed_paste->setHighlights(array_unique($to_highlight));
57 return $embed_paste;