@param Module $module

@return ModuleRendererInterface
@author Maximilian Ruta <mr@xtain.net>
354049
public function getModuleRenderer(Module $module)
    {
        $params = $module->getParams();

        if (!isset($params['service'])) {
            throw new \InvalidArgumentException(sprintf(
                'Module %s has no service parameter',
                $module->getId()
            ));
        }

        $id = $params['service'];

        if (!in_array($id, $this->moduleServices)) {
            throw new \InvalidArgumentException(sprintf(
                'Service %s is not a model service',
                $id
            ));
        }

        if (isset($this->modules[$module->getId()])) {
            return $this->modules[$module->getId()];
        }

        /** @var $service ModuleRendererInterface */
        $service = $this->modules[$module->getId()] = $this->container->get($id);
        $service->setModule($module);

        return $service;
    }
1192009
public function activateModule(DynamicModule $module)
    {
        if (!is_null($module)) {
            $module->setActive(true);
            return $this->registry->register($module);
        }

        return false;
    }
354079
public function activate(\OxidEsales\Eshop\Core\Module\Module $module)
    {
        $result = false;
        if ($moduleId = $module->getId()) {
            $this->_addExtensions($module);
            $this->_removeFromDisabledList($moduleId);

            if (version_compare($module->getMetaDataVersion(), '2.0', '<')) {
                /** Support for the key 'files' was removed in MetaData version 2.0 */
                $this->_addModuleFiles($module->getInfo("files"), $moduleId);
            }

            $this->_addTemplateBlocks($module->getInfo("blocks"), $moduleId);
            $this->_addTemplateFiles($module->getInfo("templates"), $moduleId);
            $settingsHandler = oxNew(SettingsHandler::class);
            $settingsHandler->setModuleType('module')->run($module);
            $this->_addModuleVersion($module->getInfo("version"), $moduleId);
            $this->_addModuleExtensions($module->getExtensions(), $moduleId);
            $this->_addModuleEvents($module->getInfo("events"), $moduleId);

            if (version_compare($module->getMetaDataVersion(), '2.0', '>=')) {
                try {
                    /** Support for the key 'controllers' was added in MetaData version 2.0 */
                    $this->addModuleControllers($module->getControllers(), $moduleId);
                } catch (ModuleValidationException $exception) {
                    $this->deactivate($module);
                    $lang = Registry::getLang();
                    $message = sprintf($lang->translateString('ERROR_METADATA_CONTROLLERS_NOT_UNIQUE', null, true), $exception->getMessage());

                    $standardException = oxNew(StandardException::class);
                    $standardException->setMessage($message);

                    throw $standardException;
                }
            }

            if (version_compare($module->getMetaDataVersion(), '2.1', '>=')) {
                try {
                    $this->addModuleSmartyPluginDirectories($module);
                } catch (\Exception $exception) {
                    $this->deactivate($module);

                    throw oxNew(StandardException::class, $exception->getMessage());
                }
            }

            $this->activateShopAwareServices($module);

            $this->resetCache();

            $this->_callEvent('onActivate', $moduleId);

            $result = true;
        }

        return $result;
    }
983663
public function migrateModule(ModuleContainerInterface $module)
    {
        $path = $module->getPath(['database', 'migrations']);
        $files = $this->migrator->getMigrationFiles($path);

        // Once we grab all of the migration files for the path, we will compare them
        // against the migrations that have already been run for this package then
        // run each of the outstanding migrations against a database connection.
        $ran = $this->migrator->getRepository()->getRan();

        $migrations = array_diff($files, $ran);
        $this->migrator->requireFiles($path, $migrations);

        foreach ($migrations as $migration) {
            $this->migrations[] = $migration;
        }

        return $this;
    }
97642
protected function resolveRenderer(string $extension): RendererInterface
	{
		if(!isset($this->rendererInstances[$extension]))
		{
			$this->rendererInstances[$extension] = $this->rendererFactory($this->renderers[$extension]);
		}

		return $this->rendererInstances[$extension];
	}
962994
public function getGeneratorForModule(ModuleInterface $module)
    {
        $type       = $module->getModularType();
        $collection = $this->getRouteCollectionForType($type);

        if (array_key_exists($type, $this->generators)) {
            return $this->generators[$type];
        }

        if (null === $this->options['cache_dir']) {
            return $this->generators[$type] = new $this->options['generator_class']($collection, $this->context, $this->logger);
        }

        $cacheClass = sprintf('%s_UrlGenerator', $type);

        $cache = $this->getConfigCacheFactory()->cache($this->options['cache_dir'] . '/' . $cacheClass .'.php',
            function (ConfigCacheInterface $cache) use ($cacheClass, $collection) {
                /** @var GeneratorDumperInterface $dumper */
                $dumper = new $this->options['generator_dumper_class']($collection);

                $options = [
                    'class'      => $cacheClass,
                    'base_class' => $this->options['generator_base_class'],
                ];

                $cache->write($dumper->dump($options), $collection->getResources());
            }
        );

        require_once $cache->getPath();

        return $this->generators[$type] = new $cacheClass($this->context, $this->logger);
    }
1174706
public static function getModuleAlias($module) {
        if (NULL !== $alias = static::getConfig('modules', $module, 'alias', false)) {
            return $alias;
        }

        return Util::camelToHyphen($module);
    }
728515
public function outputModule($module, $args = array(), $moduleSettings = array(), $echo = true)
    {
        if (!isset($args['id'])) {
            $args['id'] = 'no-id';
        }

        if (!is_object($module)) {
            return false;
        }

        $class = \Modularity\ModuleManager::$classes[$module->post_type];
        $module = new $class($module, $args);
        $module = $this->fillMissingParams($module, $moduleSettings);

        if (!$echo || !isset($moduleSettings['cache_ttl'])) {
            $moduleSettings['cache_ttl'] = 0;
        }

        $cache = new \Modularity\Helper\Cache($module->ID, array($module, $args['id']), $moduleSettings['cache_ttl']);

        if (empty($moduleSettings['cache_ttl']) || $cache->start()) {
            $moduleMarkup = $this->getModuleMarkup($module, $args);

            if (isset($module->columnWidth) && !empty($module->columnWidth)) {
                $moduleMarkup .= apply_filters('Modularity/Display/AfterModule', '</div>', $args, $module->post_type, $module->ID);
            } elseif (isset($this->options[$args['id']]['after_module']) && !empty($this->options[$args['id']]['after_module'])) {
                $moduleMarkup .= apply_filters('Modularity/Display/AfterModule', '</div>', $args, $module->post_type, $module->ID);
            } elseif (isset($args['after_widget'])) {
                $moduleMarkup .= apply_filters('Modularity/Display/AfterModule', $args['after_widget'], $args, $module->post_type, $module->ID);
            }

            $moduleMarkup = apply_filters('Modularity/Display/Markup', $moduleMarkup, $module);
            $moduleMarkup = apply_filters('Modularity/Display/' . $module->post_type . '/Markup', $moduleMarkup, $module);

            if (!$echo) {
                return $moduleMarkup;
            }

            echo $moduleMarkup;

            if (!empty($moduleSettings['cache_ttl'])) {
                $cache->stop();
            }
        }

        return true;
    }
334430
public static function requireModule($module)
    {
        // Check for module itself
        $file_path = DIR_MODULES . $module . '/' . 'Module' . Converter::toCamelCase($module) . '.php';
        if (file_exists($file_path)) {
            require_once $file_path;

            // Inner panel file
            if (MODE == 'cms') {
                $file_path = DIR_MODULES . $module . '/' . 'Cms' . ucfirst($module) . '.php';
                if (file_exists($file_path)) {
                    require_once $file_path;
                }
            }
        }

        // Require all Entity files
        $objects_path = DIR_MODULES . $module . '/Entity/';
        if (file_exists($objects_path)) {
            foreach (array_diff(scandir($objects_path), ['.', '..']) as $object_file) {
                if (is_file($objects_path . $object_file)) {
                    require_once $objects_path . $object_file;
                }
            }
        }
    }
1029561
private function registerVendorConfig(Module $module)
    {
        $files = $this->app['files']->files($module->getPath().'/Config/Vendor');

        foreach ($files as $file) {
            $filename = preg_replace('/\\.[^.\\s]{3,4}$/', '', basename($file));

            $this->mergeConfigFrom(
                $file,
                $filename
            );
        }
    }
1306439
public function initCompiler()
    {
        /** @var ModuleContainerInterface $this */
        if ($onRender = $this->getOption('on_render')) {
            if (isset($this->optionEvents['on_render'])) {
                $this->detach(RendererEvent::RENDER, $this->optionEvents['on_render']);
            }
            $this->attach(RendererEvent::RENDER, $onRender);
        }

        if ($onHtml = $this->getOption('on_html')) {
            if (isset($this->optionEvents['on_html'])) {
                $this->detach(RendererEvent::HTML, $this->optionEvents['on_html']);
            }
            $this->attach(RendererEvent::HTML, $onHtml);
        }

        $this->optionEvents = [
            'on_render' => $onRender,
            'on_html'   => $onHtml,
        ];

        $this->handleOptionAliases();

        $compilerClassName = $this->getOption('compiler_class_name');

        if (!is_a($compilerClassName, CompilerInterface::class, true)) {
            throw new RendererException(
                "Passed compiler class $compilerClassName is ".
                'not a valid '.CompilerInterface::class
            );
        }

        $this->compiler = new $compilerClassName($this->getOptions());
    }
836821
public function add(Module $module)
    {
        $this->modules[$module->getName()] = $module;

        if ($module instanceof RootModule) {
            $this->rootModule = $module;
        }
    }
1205396
public function deleteAllByModule($module)
    {
        $query = sprintf('DELETE FROM `%s` WHERE `module` =:module', $this->table);

        $stmt = $this->pdo->prepare($query);
        return $stmt->execute(array(
            ':'.ConstProviderInterface::CONFIG_PARAM_MODULE => $module
        ));
    }
644284
public function renderRaw($module, $theme, $template, array $vars = array())
    {
        // Save initial values before overriding theme
        $initialLayout = $this->layout;
        $initialModule = $this->module;
        $initialTheme = $this->theme;

        // Configure view with new values
        $this->setModule($module)
             ->setTheme($theme)
             ->disableLayout();

        $response = $this->render($template, $vars);

        // Restore initial values now
        $this->layout = $initialLayout;
        $this->module = $initialModule;
        $this->theme = $initialTheme;

        return $response;
    }
395658
public function setModule($module) {
        if (empty($module)) {
            throw new \Exception("Module cannot be empty", 0, null); //todo: create error code
        } else if (!is_string($module)) {
            throw new \Exception("Module must be a string", 0, null); //todo: create error code
        } else {
            $this->module = $module;
        }
    }
172239
public function getModuleCustomTable($module)
    {
        $sugarBean = $this->getBean($module);
        $customTable = $sugarBean->get_custom_table_name();
        $data = $this->db->query("SHOW TABLES LIKE '$customTable'");
        if (empty($data)) {
            return '';
        }

        return $customTable;
    }
843501
public function getClassByModule($module): ?string
    {
        if ($module instanceof Module || $module instanceof ModuleModel) {
            return Module::findClass($module->type);
        }

        if (\is_string($module)) {
            return Module::findClass($module);
        }

        return null;
    }