X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FResources%2FCollectionAdderTrait.php;h=da81a34a03d9935211646b66e49ace2441929fc6;hb=fa90126506a64cef12231590019c942284d4b36f;hp=469d1c426f880c35fcd6ce3247dd74d745164a70;hpb=8b7abdb6cf4e15bc0b20c61435dc04f9db5d45b6;p=civicrm-core.git diff --git a/CRM/Core/Resources/CollectionAdderTrait.php b/CRM/Core/Resources/CollectionAdderTrait.php index 469d1c426f..da81a34a03 100644 --- a/CRM/Core/Resources/CollectionAdderTrait.php +++ b/CRM/Core/Resources/CollectionAdderTrait.php @@ -14,7 +14,9 @@ * * This trait is a building-block for creating classes which maintain a list of * resources. It defines a set of helper functions which provide syntactic sugar - * for calling the add() method. + * for calling the add() method. It implements most of the `CollectionAdderInterface`. + * + * @see CRM_Core_Resources_CollectionAdderInterface */ trait CRM_Core_Resources_CollectionAdderTrait { @@ -36,7 +38,28 @@ trait CRM_Core_Resources_CollectionAdderTrait { * @return array * @see CRM_Core_Resources_CollectionTrait::findCreateSettingSnippet() */ - abstract protected function &findCreateSettingSnippet($options = []): array; + abstract public function &findCreateSettingSnippet($options = []): array; + + /** + * Add an HTML blob. + * + * Ex: addMarkup('

Hello world!

', ['weight' => 123]); + * + * @param string $markup + * HTML code. + * @param array $options + * Open-ended list of key-value options. See CollectionInterface docs. + * Positional equivalence: addMarkup(string $code, int $weight, string $region). + * @return static + * @see CRM_Core_Resources_CollectionInterface + * @see CRM_Core_Resources_CollectionAdderInterface::addMarkup() + */ + public function addMarkup(string $markup, ...$options) { + $this->add(self::mergeStandardOptions($options, [ + 'markup' => $markup, + ])); + return $this; + } /** * Export permission data to the client to enable smarter GUIs.