Add 'viewer' to some Remarkup callsites

Summary:
I want to implement a `{P123}` rule to embed pastes, but we need viewers everywhere before it will work with privacy.

This is not exhaustive; many Remarkup callsites haven't been converted to `PhabricatorMarkupInterface` yet.

Test Plan: Looked at Maniphest, Differential, Diffusion, Phriction; added markup, made edits and hit previews.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D3428
This commit is contained in:
epriestley
2012-09-05 11:40:48 -07:00
parent 9b843a3d44
commit dbc8218f06
10 changed files with 33 additions and 10 deletions

View File

@@ -56,6 +56,7 @@
final class PhabricatorMarkupEngine {
private $objects = array();
private $viewer;
/* -( Markup Pipeline )---------------------------------------------------- */
@@ -67,13 +68,16 @@ final class PhabricatorMarkupEngine {
*
* @param PhabricatorMarkupInterface The object to render.
* @param string The field to render.
* @param PhabricatorUser User viewing the markup.
* @return string Marked up output.
* @task markup
*/
public static function renderOneObject(
PhabricatorMarkupInterface $object,
$field) {
$field,
PhabricatorUser $viewer) {
return id(new PhabricatorMarkupEngine())
->setViewer($viewer)
->addObject($object, $field)
->process()
->getOutput($object, $field);
@@ -126,6 +130,7 @@ final class PhabricatorMarkupEngine {
$engines = array();
foreach ($objects as $key => $info) {
$engines[$key] = $info['object']->newMarkupEngine($info['field']);
$engines[$key]->setConfig('viewer', $this->viewer);
}
// Load or build the preprocessor caches.
@@ -243,9 +248,23 @@ final class PhabricatorMarkupEngine {
}
/**
* Set the viewing user. Used to implement object permissions.
*
* @param PhabricatorUser The viewing user.
* @return this
* @task markup
*/
public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
return $this;
}
/* -( Engine Construction )------------------------------------------------ */
/**
* @task engine
*/