improvements

This commit is contained in:
Andy Miller 2022-01-09 16:14:20 -07:00
parent 8767bfb9b0
commit 99ceb40c5f
No known key found for this signature in database
GPG Key ID: 9F2CF38AEBDB0AE0

View File

@ -120,6 +120,7 @@ class Assets extends PropertyObject
$this->assets_url = $locator->findResource('asset://', false);
// Initialize asset collection storage
$this->assets[self::LINK_COLLECTION] = [];
$this->assets[self::CSS_COLLECTION] = [];
$this->assets[self::JS_COLLECTION] = [];
$this->assets[self::JS_MODULE_COLLECTION] = [];
@ -476,13 +477,31 @@ class Assets extends PropertyObject
* @param array $attributes
* @return string
*/
public function css($group = 'head', $attributes = [])
public function css($group = 'head', $attributes = [], $include_link = true)
{
$output = $this->render(self::LINK, $group, $attributes);
$output = '';
if ($include_link) {
$output = $this->link($group, $attributes);
}
$output .= $this->render(self::CSS, $group, $attributes);
return $output;
}
/**
* Build the CSS link tags.
*
* @param string $group name of the group
* @param array $attributes
* @return string
*/
public function link($group = 'head', $attributes = [])
{
return $this->render(self::LINK, $group, $attributes);
}
/**
* Build the JavaScript script tags.
*
@ -490,12 +509,36 @@ class Assets extends PropertyObject
* @param array $attributes
* @return string
*/
public function js($group = 'head', $attributes = [])
public function js($group = 'head', $attributes = [], $include_js_module = true)
{
$output = $this->render(self::JS, $group, $attributes);
$output .= $this->render(self::JS_MODULE, $group, $attributes);
return $output;
if ($include_js_module) {
$output .= $this->jsModule($group, $attributes);
}
return $output;
}
/**
* Build the Javascript Modules tags
*
* @param $group
* @param $attributes
* @return string
*/
public function jsModule($group = 'head', $attributes = [])
{
return $this->render(self::JS_MODULE, $group, $attributes);
}
public function all($group = 'head', $attributes = [])
{
$output = $this->css($group, $attributes, false);
$output .= $this->link($group, $attributes);
$output .= $this->js($group, $attributes, false);
$output .= $this->jsModule($group, $attributes);
return $output;
}
protected function isValidType($type)