Back to Document class

Method addScriptOptions

public \Joomla\CMS\Document\Document
addScriptOptions
(mixed $key, mixed $options, mixed $merge = true)
Add option for script
Parameters
  • string $key Name in Storage
  • mixed $options Scrip options as array or string
  • bool $merge Whether merge with existing (true) or replace (false)
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 3.5
Class: Document
Project: Joomla

Method addScriptOptions - Source code

/**
 * Add option for script
 *
 * @param   string  $key      Name in Storage
 * @param   mixed   $options  Scrip options as array or string
 * @param   bool    $merge    Whether merge with existing (true) or replace (false)
 *
 * @return  Document instance of $this to allow chaining
 *
 * @since   3.5
 */
public function addScriptOptions($key, $options, $merge = true)
{
    if (empty($this->scriptOptions[$key])) {
        $this->scriptOptions[$key] = array();
    }
    if ($merge && \is_array($options)) {
        $this->scriptOptions[$key] = array_replace_recursive($this->scriptOptions[$key], $options);
    } else {
        $this->scriptOptions[$key] = $options;
    }
    return $this;
}