Path: blob/master/src/infrastructure/markup/PhabricatorMarkupInterface.php
12241 views
<?php12/**3* An object which has one or more fields containing markup that can be4* rendered into a display format. Commonly, the fields contain Remarkup and5* are rendered into HTML. Implementing this interface allows you to render6* objects through @{class:PhabricatorMarkupEngine} and benefit from caching7* and pipelining infrastructure.8*9* An object may have several "fields" of markup. For example, Differential10* revisions have a "summary" and a "test plan". In these cases, the `$field`11* parameter is used to identify which field is being operated on. For simple12* objects like comments, you might only have one field (say, "body"). In13* these cases, the implementation can largely ignore the `$field` parameter.14*15* @task markup Markup Interface16*/17interface PhabricatorMarkupInterface {181920/* -( Markup Interface )--------------------------------------------------- */212223/**24* Get a key to identify this field. This should uniquely identify the block25* of text to be rendered and be usable as a cache key. If the object has a26* PHID, using the PHID and the field name is likely reasonable:27*28* "{$phid}:{$field}"29*30* @param string Field name.31* @return string Cache key up to 125 characters.32*33* @task markup34*/35public function getMarkupFieldKey($field);363738/**39* Build the engine the field should use.40*41* @param string Field name.42* @return PhutilRemarkupEngine Markup engine to use.43* @task markup44*/45public function newMarkupEngine($field);464748/**49* Return the contents of the specified field.50*51* @param string Field name.52* @return string The raw markup contained in the field.53* @task markup54*/55public function getMarkupText($field);565758/**59* Callback for final postprocessing of output. Normally, you can return60* the output unmodified.61*62* @param string Field name.63* @param string The finalized output of the engine.64* @param string The engine which generated the output.65* @return string Final output.66* @task markup67*/68public function didMarkupText(69$field,70$output,71PhutilMarkupEngine $engine);727374/**75* Determine if the engine should try to use the markup cache or not.76* Generally you should use the cache for durable/permanent content but77* should not use the cache for temporary/draft content.78*79* @return bool True to use the markup cache.80* @task markup81*/82public function shouldUseMarkupCache($field);8384}858687