/**
* Maintain a set of markup/templates to inject inside various regions
*/
-class CRM_Core_Region {
+class CRM_Core_Region implements CRM_Core_Resources_CollectionInterface, CRM_Core_Resources_CollectionAdderInterface {
/**
* Obtain the content for a given region.
return Civi::$statics[__CLASS__][$name];
}
- use CRM_Core_Resources_CollectionTrait {
- CRM_Core_Resources_CollectionTrait::add as _add;
- }
+ use CRM_Core_Resources_CollectionTrait;
/**
* Symbolic name of this region
*/
public function __construct($name) {
$this->_name = $name;
- $this->types = ['markup', 'template', 'callback', 'scriptUrl', 'script', 'jquery', 'settings', 'style', 'styleUrl'];
+ $this->types = ['markup', 'template', 'callback', 'scriptFile', 'scriptUrl', 'script', 'jquery', 'settings', 'style', 'styleFile', 'styleUrl'];
$this->defaults['region'] = $name;
// Placeholder which represents any of the default content generated by the main Smarty template
$this->snippets['default']['markup'] = $default;
}
+ Civi::dispatcher()->dispatch('civi.region.render', \Civi\Core\Event\GenericHookEvent::create(['region' => $this]));
+
$this->sort();
$cms = CRM_Core_Config::singleton()->userSystem;
]);
break;
+ case 'scriptFile':
+ foreach ($snippet['scriptFileUrls'] as $url) {
+ $html .= $renderSnippet(['type' => 'scriptUrl', 'scriptUrl' => $url] + $snippet);
+ }
+ break;
+
case 'script':
if (!$allowCmsOverride || !$cms->addScript($snippet['script'], $this->_name)) {
$html .= sprintf("<script type=\"text/javascript\">\n%s\n</script>\n", $snippet['script']);
}
break;
+ case 'styleFile':
+ foreach ($snippet['styleFileUrls'] as $url) {
+ $html .= $renderSnippet(['type' => 'styleUrl', 'styleUrl' => $url] + $snippet);
+ }
+ break;
+
case 'styleUrl':
if (!$allowCmsOverride || !$cms->addStyleUrl($snippet['styleUrl'], $this->_name)) {
$html .= sprintf("<link href=\"%s\" rel=\"stylesheet\" type=\"text/css\"/>\n", $snippet['styleUrl']);