Returns an array of module data
@param string $module_id
@return array
170090
public function get($module_id)
    {
        $modules = $this->getList();
        return empty($modules[$module_id]) ? array() : $modules[$module_id];
    }
415864
public function getSettings($module_id, $key = null, $default = null)
    {
        $module = $this->get($module_id);

        if (empty($module['settings'])) {
            return $default;
        }

        if (!isset($key)) {
            return (array) $module['settings'];
        }

        $value = gplcart_array_get($module['settings'], $key);
        return isset($value) ? $value : $default;
    }
615306
public function parseModules($modules, $moduleType)
    {
        // distinguish between 'modules' command-line argument
        // which has module data in colon-separated format
        // and properly-formatted 'modules' array
        // generated through previous methods
        if (is_array($modules)) {
            if (isset($modules[0]['module_name'])) {
                return $modules;
            }
        }

        $newModules = array();

        foreach ($modules as $module) {
            $data = explode(':', $module);

            if (count($newModules) == 0) {
                $moduleName = Validators::validateModuleName($data[0], false);
                $moduleNameSuffix = Validators::validateModuleNameSuffix($data[1], false);
            } else {
                $moduleName = $newModules[0]['module_name'];
                $moduleNameSuffix = Validators::validateModuleNameSuffix($data[1], $newModules, true, false);
            }
            $moduleNameUnderscore = strtolower(str_replace(' ', '_', $moduleName));
            $moduleNameHyphen = strtolower(str_replace(' ', '-', $moduleName));
            $moduleNameSuffixUnderscore = strtolower(str_replace(' ', '_', $moduleNameSuffix));
            $moduleNameSuffixHyphen = strtolower(str_replace(' ', '-', $moduleNameSuffix));
            $moduleDisplayName = Validators::validateDisplayName($data[2], false);
            $moduleDescription = Validators::validateDescription($data[3], false);
            $derivedClassName = implode('', array_map('ucwords', explode('-', $moduleNameHyphen . '-' . $moduleNameSuffix)));
            if ($moduleType == 'operation') {
                $operationOwnsLocation = Validators::validateOperationOwnsLocation($data[4], false);
                $metricsForOperation = Validators::validateMetricsForOperation($data[5], false);
            }
            if ($moduleType == 'activity') {
                $channelsForActivity = Validators::validateChannelsForActivity($data[4], false);
                $hooksForActivity = Validators::validateHooksForActivity($data[5], false);
            }

            $newModules[] = array(
                'module_name'                   => $moduleName,
                'module_name_underscore'        => $moduleNameUnderscore,
                'module_name_hyphen'            => $moduleNameHyphen,
                'module_name_suffix'            => $moduleNameSuffix,
                'module_name_suffix_underscore' => $moduleNameSuffixUnderscore,
                'module_name_suffix_hyphen'     => $moduleNameSuffixHyphen,
                'module_display_name'           => $moduleDisplayName,
                'module_description'            => $moduleDescription,
                'operation_owns_location'       => !empty($operationOwnsLocation) ? $operationOwnsLocation : null,
                'channels_for_activity'         => !empty($channelsForActivity) ? explode(',', $channelsForActivity) : null,
                'hooks_for_activity'            => !empty($hooksForActivity) ? explode(',', $hooksForActivity) : null,
                'metrics_for_operation'         => !empty($metricsForOperation) ? explode(',', $metricsForOperation) : null,
                'class_name'                    => $derivedClassName
            );
        }
        return $newModules;
    }
735171
private static function get_all_licenses( $module_id = null ) {
            $licenses = self::get_account_option( 'all_licenses' );

            if ( ! is_array( $licenses ) ) {
                $licenses = array();
            }

            if ( is_null( $module_id ) ) {
                return $licenses;
            }

            $licenses = isset( $licenses[ $module_id ] ) ?
                $licenses[ $module_id ] :
                array();

            return $licenses;
        }
459019
public function getFiles($module_root_name) {
    $filepath = $this->environment->getExtensionPath('module', $module_root_name);

    //$old_dir = getcwd();
    //chdir($filepath);
    $files = scandir($filepath);

    foreach ($files as $filename) {
      $ext = substr(strrchr($filename, '.'), 1);
      if (in_array($ext, array('module', 'install', 'inc'))) {
        $module_files[] = $filepath . '/' . $filename;
      }
    }

    return $module_files;
  }
944865
protected function setModule($module_id)
    {
        $this->data_module = $this->module->get($module_id);

        if (empty($this->data_module)) {
            $this->outputHttpStatus(403);
        }
    }
636694
public function getModule() {
		
		$class	= 'Module';
		$id		= $this->moduleId;
		
		if (!$this->issetCache($class)) {
			$this->setCache($class, new Module($id));
		}
		
		return $this->getCache($class);
		
	}
904951
public function getAllModules(\MultiColumnWizard $multiColumnWizard = null): array
    {
        if ($multiColumnWizard
            && $multiColumnWizard->dataContainer
            && $multiColumnWizard->dataContainer->activeRecord) {
            $collection = ModuleModel::findBy(
                ['tl_module.pid = ?', 'tl_module.id != ?'],
                [
                    $multiColumnWizard->dataContainer->activeRecord->pid,
                    $multiColumnWizard->dataContainer->activeRecord->id
                ]
            );
        } else {
            $collection = ModuleModel::findAll();
        }

        $modules = [
            'grid' => [
                'separator' => $GLOBALS['TL_LANG']['tl_module']['bs_separatorTitle']
            ]
        ];

        if ($collection) {
            foreach ($collection as $model) {
                $label = isset($GLOBALS['TL_LANG']['FMD'][$model->type][0])
                    ? $GLOBALS['TL_LANG']['FMD'][$model->type][0]
                    : $model->type;

                $modules['module'][$model->id] = sprintf('%s [%s]', $model->name, $label);
            }
        }

        return $modules;
    }
1372133
public static function get_modules_from_sectionid($sectionid) {
        global $DB;

        // Get the course and sequence of the section
        $secrec = $DB->get_record('course_sections', array('id' => $sectionid), 'course, sequence');
        $courseid = $secrec->course;
        $sequence = $secrec->sequence;

        // Get the section->sequence contents (it roots the activities order)
        // Get all course modules belonging to requested section
        $modulesarr = array();
        $modules = $DB->get_records_sql("
            SELECT cm.id, m.name AS modname
              FROM {course_modules} cm
              JOIN {modules} m ON m.id = cm.module
             WHERE cm.course = ?
               AND cm.section = ?
               AND cm.deletioninprogress <> 1", array($courseid, $sectionid));
        foreach (explode(',', $sequence) as $moduleid) {
            if (isset($modules[$moduleid])) {
                $module = array('id' => $modules[$moduleid]->id, 'modname' => $modules[$moduleid]->modname);
                $modulesarr[] = (object)$module;
                unset($modules[$moduleid]);
            }
        }
        if (!empty($modules)) { // This shouldn't happen, but one borked sequence can lead to it. Add the rest
            foreach ($modules as $module) {
                $module = array('id' => $module->id, 'modname' => $module->modname);
                $modulesarr[] = (object)$module;
            }
        }
        return $modulesarr;
    }
442369
public function getModifiedData($id)
    {
        $result = [];
        if (isset($this->modified[$id])) {
            foreach (array_keys($this->modified[$id]) as $column) {
                $result[$column] = $this->data[$id][$column];
            }
        }
        return $result;
    }
1120287
protected function getModule($moduleConfig)
    {
        if (!file_exists($moduleConfig)) {
            return [];
        }

        $moduleConfigContent = file_get_contents($moduleConfig);

        return Yaml::parse($moduleConfigContent);
    }
382508
protected function getListModule()
    {
        $id = $this->getParam(0);

        if (!isset($id)) {
            $list = $this->module->getList();
            $this->limitArray($list);
            return $list;
        }

        $module = $this->module->get($id);

        if (empty($module)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        return array($module);

    }
33449
protected function getCSVModuleAttr(string $moduleName) : array
    {
        if (empty($this->modules[$moduleName])) {
            return [];
        }

        return $this->modules[$moduleName];
    }
787106
protected function preCompileModules(array $moduleIds): array
    {
        $collection = ModuleModel::findMultipleByIds($moduleIds);
        $modules    = [];

        if ($collection) {
            foreach ($collection as $model) {
                $modules[$model->id] = Controller::getFrontendModule($model, $this->getColumn());
            }
        }

        return $modules;
    }
1334774
protected function getListData(string $module, string $listName) : array
    {
        $mc = new ModuleConfig(ConfigType::LISTS(), $module, $listName);
        try {
            $config = $mc->parseToArray();
            $listData = array_key_exists('items', $config) ? $config['items'] : [];
        } catch (InvalidArgumentException $e) {
            return [];
        }

        if (empty($listData)) {
            return [];
        }

        $result = [];
        foreach ($listData as $key => $data) {
            if ($data['inactive'] == '1') {
                continue;
            }
            $result[] = $key;
        }

        return $result;
    }
1023273
public function getShortcodeModules($post_id) : array
    {
        $post = get_post($post_id);
        $pattern = get_shortcode_regex();
        $modules = array();

        if (is_object($post) && preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches)
            && array_key_exists(2, $matches)
            && in_array('modularity', $matches[2])) {

            $shortcodes = preg_replace('/[^0-9]/', '', $matches[3]);
            foreach ($shortcodes as $key => $shortcode) {
                $modules[] = array(
                    'ID' => $shortcode,
                    'post_type' => get_post_type($shortcode)
                );
            }
        }

        return $modules;
    }
404569
private static function get_all_plans( $module_type = false ) {
            $plans = self::get_account_option( 'plans', $module_type );

            if ( ! is_array( $plans ) ) {
                $plans = array();
            }

            return $plans;
        }