Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.2] Move check for discoverable extensions to model #37605

Merged
merged 6 commits into from Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions administrator/components/com_installer/src/Model/DiscoverModel.php
Expand Up @@ -305,4 +305,24 @@ protected function getEmptyStateQuery()

return $query;
}

/**
* Checks uninstalled extensions in extensions table.
laoneo marked this conversation as resolved.
Show resolved Hide resolved
*
* @return boolean True if there are discovered extensions on the database.
laoneo marked this conversation as resolved.
Show resolved Hide resolved
*
* @since __DEPLOY_VERSION__
*/
public function checkExtensions()
{
$db = $this->getDatabase();
$query = $db->getQuery(true)
->select('*')
->from($db->quoteName('#__extensions'))
->where($db->quoteName('state') . ' = -1');
$db->setQuery($query);
$discoveredExtensions = $db->loadObjectList();

return count($discoveredExtensions) > 0;
}
}
Expand Up @@ -43,9 +43,9 @@ class HtmlView extends InstallerViewDefault
public function display($tpl = null)
{
// Run discover from the model.
if (!$this->checkExtensions())
if (!$this->getModel()->checkExtensions())
{
$this->getModel('discover')->discover();
$this->getModel()->discover();
}

// Get data from the model.
Expand Down Expand Up @@ -92,26 +92,4 @@ protected function addToolbar()

ToolbarHelper::help('Extensions:_Discover');
}

/**
* Check extensions.
*
* Checks uninstalled extensions in extensions table.
*
* @return boolean True if there are discovered extensions on the database.
*
* @since 3.5
*/
public function checkExtensions()
{
$db = Factory::getDbo();
laoneo marked this conversation as resolved.
Show resolved Hide resolved
$query = $db->getQuery(true)
->select('*')
->from($db->quoteName('#__extensions'))
->where($db->quoteName('state') . ' = -1');
$db->setQuery($query);
$discoveredExtensions = $db->loadObjectList();

return (count($discoveredExtensions) === 0) ? false : true;
}
}