Backend\Modules\Extensions\Engine\Model::installModule PHP Method

installModule() public static method

Install a module.
public static installModule ( string $module )
$module string The name of the module to be installed.
    public static function installModule($module)
    {
        $class = 'Backend\\Modules\\' . $module . '\\Installer\\Installer';
        $variables = array();
        // run installer
        $installer = new $class(BackendModel::getContainer()->get('database'), BL::getActiveLanguages(), array_keys(BL::getInterfaceLanguages()), false, $variables);
        $installer->install();
        // clear the cache so locale (and so much more) gets rebuilt
        self::clearCache();
    }

Usage Example

Example #1
0
 /**
  * Execute the action.
  */
 public function execute()
 {
     // get parameters
     $this->currentModule = $this->getParameter('module', 'string');
     // does the item exist
     if ($this->currentModule !== null && BackendExtensionsModel::existsModule($this->currentModule)) {
         // call parent, this will probably add some general CSS/JS or other required files
         parent::execute();
         // make sure this module can be installed
         $this->validateInstall();
         // do the actual install
         BackendExtensionsModel::installModule($this->currentModule);
         // remove our container cache after this request
         $filesystem = new Filesystem();
         $filesystem->remove($this->getContainer()->getParameter('kernel.cache_dir'));
         // redirect to index with a success message
         $this->redirect(BackendModel::createURLForAction('Modules') . '&report=module-installed&var=' . $this->currentModule . '&highlight=row-module_' . $this->currentModule);
     } else {
         // no item found, redirect to index, because somebody is f*****g with our url
         $this->redirect(BackendModel::createURLForAction('Modules') . '&error=non-existing');
     }
 }
All Usage Examples Of Backend\Modules\Extensions\Engine\Model::installModule