Back to LibraryHelper class

Method saveParams

public static \Joomla\Registry\Registry|bool
saveParams
(mixed $element, mixed $params)
Save the parameters object for the library
Parameters
  • string $element Element of the library in the extensions table.
  • \Joomla\Registry\Registry $params Params to save
Returns
  • \Joomla\Registry\Registry|bool A Registry object.
Since
  • 3.2
-
  • \Joomla\Registry\Registry
Class: LibraryHelper
Project: Joomla

Method saveParams - Source code

/**
 * Save the parameters object for the library
 *
 * @param   string    $element  Element of the library in the extensions table.
 * @param   Registry  $params   Params to save
 *
 * @return  Registry|boolean  A Registry object.
 *
 * @see     Registry
 * @since   3.2
 */
public static function saveParams($element, $params)
{
    if (static::isEnabled($element)) {
        // Save params in DB
        $db = Factory::getDbo();
        $paramsString = $params->toString();
        $query = $db->getQuery(true)->update($db->quoteName('#__extensions'))->set($db->quoteName('params') . ' = :params')->where($db->quoteName('type') . ' = ' . $db->quote('library'))->where($db->quoteName('element') . ' = :element')->bind(':params', $paramsString)->bind(':element', $element);
        $db->setQuery($query);
        $result = $db->execute();
        // Update params in libraries cache
        if ($result && isset(static::$libraries[$element])) {
            static::$libraries[$element]->params = $params;
        }
        return $result;
    }
    return false;
}