public function install(InputInterface $input, OutputInterface $output) { $app = Bootstrapper::getApplication($this->target_dir); // Output buffer is used as a guard against Joomla including ._ files when searching for adapters // See: http://kadin.sdf-us.org/weblog/technology/software/deleting-dot-underscore-files.html ob_start(); $installer = $app->getInstaller(); $installer->discover(); require_once $app->getPath() . '/administrator/components/com_installer/models/discover.php'; $model = new \InstallerModelDiscover(); $model->discover(); $results = $model->getItems(); $install = array(); foreach ($results as $result) { if ($result->element === 'com_extman') { array_unshift($install, $result->extension_id); } if ($result->type === 'component' && (in_array(substr($result->element, 4), $this->extension) || in_array($result->element, $this->extension))) { $install[] = $result->extension_id; } } ob_end_clean(); if (class_exists('Koowa') && !class_exists('ComExtmanDatabaseRowExtension')) { \KObjectManager::getInstance()->getObject('com://admin/extman.database.row.extension'); } $install = array_unique($install); foreach ($install as $extension_id) { try { $installer->discover_install($extension_id); } catch (\Exception $e) { $output->writeln("<info>Caught exception during install: " . $e->getMessage() . "</info>\n"); } } }
public function install(InputInterface $input, OutputInterface $output) { $app = Bootstrapper::getApplication($this->target_dir); $db = \JFactory::getDbo(); // Output buffer is used as a guard against Joomla including ._ files when searching for adapters // See: http://kadin.sdf-us.org/weblog/technology/software/deleting-dot-underscore-files.html ob_start(); $installer = $app->getInstaller(); $installer->discover(); require_once JPATH_ADMINISTRATOR . '/components/com_installer/models/discover.php'; $model = new \InstallerModelDiscover(); $model->discover(); $results = $model->getItems(); ob_end_clean(); $install = array(); $plugins = array(); foreach ($this->extensions as $extension) { foreach ($results as $result) { $included = false; if (in_array($result->element, array('com_extman', 'koowa')) && ($extension == 'all' || $extension == $result->element)) { array_unshift($install, $result); $included = true; } elseif ($extension == 'all' || in_array($extension, array($result->element, substr($result->element, 4)))) { $install[] = $result; $included = true; } if ($result->type == 'plugin' && $included) { $plugins[] = $result->extension_id; } if ($included && $output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $output->writeln("Queued {$result->name} for installation."); } } } foreach ($install as $extension) { if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $output->writeln("Installing {$extension->element} .."); } try { $installer->discover_install($extension->extension_id); } catch (\Exception $e) { $output->writeln("<info>Caught exception whilst installing {$extension->type} {$extension->element}: " . $e->getMessage() . "</info>\n"); } if (in_array($extension->extension_id, $plugins)) { if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $output->writeln("Enabling plugin `{$extension->element}` (ID #{$extension->extension_id}) .."); } $sql = "UPDATE `#__extensions` SET `enabled` = 1 WHERE `extension_id` = '{$extension->extension_id}'"; $db->setQuery($sql); $db->execute(); switch ($extension->element) { case 'com_extman': if (class_exists('Koowa') && !class_exists('ComExtmanDatabaseRowExtension')) { \KObjectManager::getInstance()->getObject('com://admin/extman.database.row.extension'); } break; case 'koowa': $path = JPATH_PLUGINS . '/system/koowa/koowa.php'; if (!file_exists($path)) { return; } require_once $path; if (class_exists('\\PlgSystemKoowa')) { $dispatcher = \JEventDispatcher::getInstance(); new \PlgSystemKoowa($dispatcher, (array) \JPLuginHelper::getPLugin('system', 'koowa')); } if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $output->writeln("Initialised new PlgSystemKoowa instance"); } break; } } } }