*
* 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 {
* @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('<p>Hello world!</p>', ['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.