/** * Push CSS to the document * * @param string $stylesheet Stylesheet or styles to add * @param string $extension Extension name, e.g.: com_example, mod_example, plg_example_test * @param string $element Plugin element. Only used for plugins and if first argument is folder name. * @return object */ public function css($stylesheet = '', $extension = null, $element = null) { $extension = $extension ?: $this->detectExtensionName(); $attr = array('type' => 'text/css', 'media' => null, 'attribs' => array()); if ($element) { if (is_string($element)) { $extension = 'plg_' . $extension . '_' . $element; } else { if (is_array($element)) { foreach ($element as $key => $val) { if (array_key_exists($key, $attr)) { $attr[$key] = $val; } } } } } $asset = new Stylesheet($extension, $stylesheet); if ($asset->exists()) { if ($asset->isDeclaration()) { \App::get('document')->addStyleDeclaration($asset->contents()); } else { \App::get('document')->addStyleSheet($asset->link(), $attr['type'], $attr['media'], $attr['attribs']); } } return $this; }
/** * Push CSS to the document * * @param string $stylesheet Stylesheet or styles to add * @param string $extension Extension name, e.g.: com_example, mod_example, plg_example_test * @param string $element Plugin element. Only used for plugins and if first argument is folder name. * @return object */ public function __invoke($stylesheet = '', $extension = null, $element = null) { $extension = $extension ?: $this->_extension(); if ($element) { $extension = 'plg_' . $extension . '_' . $element; } $asset = new Stylesheet($extension, $stylesheet); if ($asset->exists()) { if ($asset->isDeclaration()) { Document::addStyleDeclaration($asset->contents()); } else { Document::addStyleSheet($asset->link()); } } return $this->getView(); }