Back to PackageAdapter class

Method _getExtensionId

protected int
_getExtensionId
(mixed $type, mixed $id, mixed $client, mixed $group)
Gets the extension id.
Parameters
  • string $type The extension type.
  • string $id The name of the extension (the element field).
  • int $client The application id (0: Joomla CMS site; 1: Joomla CMS administrator).
  • string $group The extension group (mainly for plugins).
Returns
  • int
Since
  • 3.1

Method _getExtensionId - Source code

/**
 * Gets the extension id.
 *
 * @param   string   $type    The extension type.
 * @param   string   $id      The name of the extension (the element field).
 * @param   integer  $client  The application id (0: Joomla CMS site; 1: Joomla CMS administrator).
 * @param   string   $group   The extension group (mainly for plugins).
 *
 * @return  integer
 *
 * @since   3.1
 */
protected function _getExtensionId($type, $id, $client, $group)
{
    $db = $this->parent->getDbo();
    $query = $db->getQuery(true)->select($db->quoteName('extension_id'))->from($db->quoteName('#__extensions'))->where([$db->quoteName('type') . ' = :type', $db->quoteName('element') . ' = :element'])->bind(':type', $type)->bind(':element', $id);
    switch ($type) {
        case 'plugin':
            // Plugins have a folder but not a client
            $query->where('folder = :folder')->bind(':folder', $group);
            break;
        case 'library':
        case 'package':
        case 'component':
            // Components, packages and libraries don't have a folder or client.
            // Included for completeness.
            break;
        case 'language':
        case 'module':
        case 'template':
            // Languages, modules and templates have a client but not a folder
            $clientId = ApplicationHelper::getClientInfo($client, true)->id;
            $query->where('client_id = :client_id')->bind(':client_id', $clientId, ParameterType::INTEGER);
            break;
    }
    $db->setQuery($query);
    // Note: For templates, libraries and packages their unique name is their key.
    // This means they come out the same way they came in.
    return $db->loadResult();
}