FOF30\Update\Update::getUpdates PHP Метод

getUpdates() публичный Метод

hasUpdate True if an update is available version The version of the available update infoURL The URL to the download page of the update
public getUpdates ( boolean $force = false ) : array
$force boolean Set to true if you want to forcibly reload the update information
Результат array See the method description for more information
    public function getUpdates($force = false)
    {
        $db = $this->container->db;
        // Default response (no update)
        $updateResponse = array('hasUpdate' => false, 'version' => '', 'infoURL' => '');
        if (empty($this->extension_id)) {
            return $updateResponse;
        }
        // If we are forcing the reload, set the last_check_timestamp to 0
        // and remove cached component update info in order to force a reload
        if ($force) {
            // Find the update site IDs
            $updateSiteIds = $this->getUpdateSiteIds();
            if (empty($updateSiteIds)) {
                return $updateResponse;
            }
            // Set the last_check_timestamp to 0
            $query = $db->getQuery(true)->update($db->qn('#__update_sites'))->set($db->qn('last_check_timestamp') . ' = ' . $db->q('0'))->where($db->qn('update_site_id') . ' IN (' . implode(', ', $updateSiteIds) . ')');
            $db->setQuery($query);
            $db->execute();
            // Remove cached component update info from #__updates
            $query = $db->getQuery(true)->delete($db->qn('#__updates'))->where($db->qn('update_site_id') . ' IN (' . implode(', ', $updateSiteIds) . ')');
            $db->setQuery($query);
            $db->execute();
        }
        // Use the update cache timeout specified in com_installer
        $comInstallerParams = \JComponentHelper::getParams('com_installer', false);
        $timeout = 3600 * $comInstallerParams->get('cachetimeout', '6');
        // Load any updates from the network into the #__updates table
        $this->updater->findUpdates($this->extension_id, $timeout);
        // Get the update record from the database
        $query = $db->getQuery(true)->select('*')->from($db->qn('#__updates'))->where($db->qn('extension_id') . ' = ' . $db->q($this->extension_id));
        $db->setQuery($query);
        $updateRecord = $db->loadObject();
        // If we have an update record in the database return the information found there
        if (is_object($updateRecord)) {
            $updateResponse = array('hasUpdate' => true, 'version' => $updateRecord->version, 'infoURL' => $updateRecord->infourl);
        }
        return $updateResponse;
    }