/**
*
*
* @param null $AddonCode
* @param bool $Explicit
* @param bool $Drop
* @throws Exception
*/
public function runStructure($AddonCode = null, $Explicit = false, $Drop = false)
{
// Get the structure files for all of the enabled applications.
$ApplicationManager = new Gdn_ApplicationManager();
$Apps = $ApplicationManager->enabledApplications();
$AppNames = consolidateArrayValuesByKey($Apps, 'Folder');
$Paths = array();
foreach ($Apps as $Key => $AppInfo) {
$Path = PATH_APPLICATIONS . "/{$AppInfo['Folder']}/settings/structure.php";
if (file_exists($Path)) {
$Paths[] = $Path;
}
Gdn::applicationManager()->registerPermissions($Key, $this->Validation);
}
// Execute the structures.
$Database = Gdn::database();
$SQL = Gdn::sql();
$Structure = Gdn::structure();
foreach ($Paths as $Path) {
include $Path;
}
// Execute the structures for all of the plugins.
$PluginManager = Gdn::pluginManager();
$Registered = $PluginManager->registeredPlugins();
foreach ($Registered as $ClassName => $Enabled) {
if (!$Enabled) {
continue;
}
try {
$Plugin = $PluginManager->getPluginInstance($ClassName, Gdn_PluginManager::ACCESS_CLASSNAME);
if (method_exists($Plugin, 'Structure')) {
trace("{$ClassName}->Structure()");
$Plugin->structure();
}
} catch (Exception $Ex) {
// Do nothing, plugin wouldn't load/structure.
if (Debug()) {
throw $Ex;
}
}
}
$this->fireEvent('AfterStructure');
}