Back to ExtensionDiscoverInstallCommand class

Method processDiscover

public int
processDiscover
(mixed $eid)
Used for discovering extensions
Parameters
  • string $eid Id of the extension
Returns
  • int The count of installed extensions
Since
  • 4.0.0
-
  • \Exception

Method processDiscover - Source code

/**
 * Used for discovering extensions
 *
 * @param   string  $eid  Id of the extension
 *
 * @return  integer  The count of installed extensions
 *
 * @throws  \Exception
 * @since   4.0.0
 */
public function processDiscover($eid) : int
{
    $jInstaller = new Installer();
    $count = 0;
    if ($eid === -1) {
        $db = $this->db;
        $query = $db->getQuery(true)->select($db->quoteName(['extension_id']))->from($db->quoteName('#__extensions'))->where($db->quoteName('state') . ' = -1');
        $db->setQuery($query);
        $eidsToDiscover = $db->loadObjectList();
        foreach ($eidsToDiscover as $eidToDiscover) {
            if (!$jInstaller->discover_install($eidToDiscover->extension_id)) {
                return -1;
            }
            $count++;
        }
        if (empty($eidsToDiscover)) {
            return 0;
        }
    } else {
        if ($jInstaller->discover_install($eid)) {
            return 1;
        } else {
            return -1;
        }
    }
    return $count;
}