@author Leo Fajardo (@leorw)
@since  1.2.2

@param  string|bool $module_type "plugin", "theme", or "false" for all modules.

@return array
768130
protected function get_all_modules( $module_type = false ) {
			$option_manager = $this->get_option_manager();

			if ( false !== $module_type ) {
				return $option_manager->get_option( $module_type . 's', array() );
			}

			return array(
				self::OPTION_NAME_PLUGINS => $option_manager->get_option( self::OPTION_NAME_PLUGINS, array() ),
				self::OPTION_NAME_THEMES  => $option_manager->get_option( self::OPTION_NAME_THEMES, array() ),
			);
		}
606660
public function modes($type = false){
    if ( \defined('BBN_DATA_PATH') ){
      $r = [
        'html' => [
          'name' => 'HTML',
          'mode' => 'htmlmixed',
          'code' => is_file(BBN_DATA_PATH.'ide/defaults/default.html') ? file_get_contents(BBN_DATA_PATH.'ide/defaults/default.html') : ''
        ],
        'xml' => [
          'name' => 'XML',
          'mode' => 'text/xml',
          'code' => is_file(BBN_DATA_PATH.'ide/defaults/default.xml') ? file_get_contents(BBN_DATA_PATH.'ide/defaults/default.xml') : ''
        ],
        'js' => [
          'name' => 'JavaScript',
          'mode' => 'javascript',
          'code' => is_file(BBN_DATA_PATH.'ide/defaults/default.js') ? file_get_contents(BBN_DATA_PATH.'ide/defaults/default.js') : ''
        ],
        'svg' => [
          'name' => 'SVG',
          'mode' => 'text/xml',
          'code' => is_file(BBN_DATA_PATH.'ide/defaults/default.svg') ? file_get_contents(BBN_DATA_PATH.'ide/defaults/default.svg') : ''
        ],
        'php' => [
          'name' => 'PHP',
          'mode' => 'application/x-httpd-php',
          'code' => is_file(BBN_DATA_PATH.'ide/defaults/default.php') ? file_get_contents(BBN_DATA_PATH.'ide/defaults/default.php') : ''
        ],
        'css' => [
          'name' => 'CSS',
          'mode' => 'text/css',
          'code' => is_file(BBN_DATA_PATH.'ide/defaults/default.css') ? file_get_contents(BBN_DATA_PATH.'ide/defaults/default.css') : ''
        ],
        'less' => [
          'name' => 'LESS',
          'mode' => 'text/x-less',
          'code' => is_file(BBN_DATA_PATH.'ide/defaults/default.css') ? file_get_contents(BBN_DATA_PATH.'ide/defaults/default.css') : ''
        ],
        'sql' => [
          'name' => 'SQL',
          'mode' => 'text/x-sql',
          'code' => is_file(BBN_DATA_PATH.'ide/defaults/default.sql') ? file_get_contents(BBN_DATA_PATH.'ide/defaults/default.sql') : ''
        ],
        'def' => [
          'mode' => 'application/x-httpd-php',
          'code' => is_file(BBN_DATA_PATH.'ide/defaults/default.php') ? file_get_contents(BBN_DATA_PATH.'ide/defaults/default.php') : ''
        ]
      ];
      return $type ? ( isset($r[$type]) ? $r[$type] : false ) : $r;
    }
    return false;
  }
718220
public function disable($module_id)
    {
        try {
            $result = $this->canDisable($module_id);
        } catch (Exception $ex) {
            $result = $ex->getMessage();
        }

        $this->hook->attach("module.disable.before|$module_id", $result, $this);

        if ($result !== true) {
            return $result;
        }

        if ($this->module->isInstalled($module_id)) {
            $this->module->update($module_id, array('status' => false));
        } else {
            $this->module->add(array('status' => false, 'module_id' => $module_id));
        }

        $this->setOverrideConfig();

        $this->hook->attach("module.disable.after|$module_id", $result, $this);
        return $result;
    }
272398
public function getModulePlugins($excludeModulesOnReturn = array())
    {
        $modules = array();
        $excludeModules = array_values($this->getCoreModules());
        foreach($this->getAllModules() as $module) {
            if(!in_array($module, array_merge($excludeModules,$excludeModulesOnReturn))) {
                $modules[] = $module;
            }
        }
        return $modules;
    }
299112
private function getModuleProposal()
    {
        $moduleNames = [];
        foreach (Yii::$app->getApplicationModules() as $id => $obj) {
            $moduleNames[$id] = $id;
        }

        return $moduleNames;
    }
539067
public function getFrontendModules()
    {
        $modules = [];

        foreach ($this->getModules() as $id => $obj) {
            if ($obj instanceof Module && !$obj instanceof AdminModuleInterface && !$obj instanceof CoreModuleInterface) {
                $modules[$id] = $obj;
            }
        }

        return $modules;
    }
1180916
public function otherModules(bool $include_disabled = false): Collection
    {
        return $this->findByInterface(ModuleInterface::class, $include_disabled, true)
            ->filter(static function (ModuleInterface $module): bool {
                foreach (self::COMPONENTS as $interface) {
                    if ($module instanceof $interface) {
                        return false;
                    }
                }

                return true;
            });
    }
1017369
protected function getTypesModule()
    {
        $types = array();

        foreach ($this->module->getList() as $module) {
            $types[$module['type']] = $this->text(ucfirst($module['type']));
        }

        return $types;
    }
1011046
public static function get_mod_name($type) {
        static $types;

        if (!is_array($types)) {
            global $DB;
            $types = $DB->get_records('modules');
        }

        return $types[$type]->name;
    }
19214
protected function getPluginTypes($pattern, $plugin_path)
    {
        $types = [];
        $project_root = ProjectX::projectRoot();

        foreach ($this->getInstalledPluginNamespaces() as $name => $namespace) {
            $plugin_dir = "$project_root/vendor/$name";

            if (!file_exists($plugin_dir)) {
                continue;
            }
            $plugin_dir = "$plugin_dir/src";

            if (isset($plugin_path)) {
                $plugin_dir = "$plugin_dir/$plugin_path";
            }

            if (!file_exists($plugin_dir)) {
                continue;
            }

            $classes = (new PhpClassDiscovery)
                ->setSearchPattern($pattern)
                ->addSearchLocation($plugin_dir)
                ->discover();

            foreach ($classes as $classname) {
                if (!class_exists($classname)) {
                    continue;
                }

                $types[$classname::getTypeId()] = $classname;
            }
        }

        return $types;
    }
92021
public function getModulesAsArray()
    {

        // initialize the array for the modules
        $modules = array();

        // iterate over the module nodes and sort them into an array
        /** @var \AppserverIo\Appserver\Core\Api\Node\ModuleNode $module */
        foreach ($this->getModules() as $module) {
            $modules[$module->getUuid()] = $module->getType();
        }

        // return the array
        return $modules;
    }
153256
public function getApplicationModules()
    {
        $modules = [];

        foreach ($this->getModules() as $id => $obj) {
            if ($obj instanceof Module) {
                $modules[$id] = $obj;
            }
        }

        return $modules;
    }
731310
public function getEntityBundles(array $module_configs) {
    $list = [];
    foreach ($this->entityBundlesConfigPrefixes as $entity_type => $data) {
      $filtered_array = preg_grep('/^' . $data['prefix'] . '.*/', $module_configs);
      if (empty($filtered_array)) {
        continue;
      }

      foreach ($filtered_array as $config_name) {
        // Example - paragraphs.paragraphs_type.blog_posts_listing.
        // Example - taxonomy.vocabulary.amenities.
        // Example - node.type.landing_page.
        // Last array item always entity bundle name.
        $entity_info = explode('.', $config_name);
        $list[] = [
          'entity_type' => $entity_type,
          'config_entity_type' => $data['config_entity_type'],
          'bundle' => end($entity_info),
          'bundle_field' => $data['bundle_field'],
        ];
      }
    }

    return $list;
  }
1215770
public function getOnePageModules() : array
    {
        $modules = array();

        if (is_front_page() && is_plugin_active('modularity-onepage/modularity-onepage.php')) {
            $postStatus = array('publish');
            if (is_user_logged_in()) {
                $postStatus[] = 'private';
            }

            $sections = get_posts(array(
                'post_type' => 'onepage',
                'post_status' => $postStatus,
                'orderby' => 'menu_order',
                'order' => 'asc',
                'posts_per_page'   => -1
            ));

            foreach ($sections as $section) {
                $section_modules = \Modularity\Editor::getPostModules($section->ID);

                if (!isset($section_modules['onepage-sidebar'])) {
                    continue;
                }

                $section_modules = $section_modules['onepage-sidebar']['modules'];
                if (is_array($section_modules) && !empty($section_modules)) {
                    foreach ($section_modules as $module) {
                        if (!$module->hidden) {
                            $modules[] = $module;
                        }
                    }
                }
            }
        }

        return $modules;
    }
1295799
public function metaBoxModules()
    {
	$available = \Modularity\ModuleManager::$available;

	uasort($available, function ($a, $b) {
	    return strcmp($a['labels']['name'], $b['labels']['name']);
	});

	global $modularityOptions;
	$enabled = isset($modularityOptions['enabled-modules']) && is_array($modularityOptions['enabled-modules']) ? $modularityOptions['enabled-modules'] : array();

	$templatePath = \Modularity\Helper\Wp::getTemplate('modules', 'options/partials');
	include $templatePath;
    }
240947
public function checkDependentModules($module_id, array $modules)
    {
        unset($modules[$module_id]);

        $required_by = array();

        foreach ($modules as $info) {

            if (empty($info['dependencies'])) {
                continue;
            }

            foreach (array_keys($info['dependencies']) as $dependency) {
                if ($dependency === $module_id && !empty($info['status'])) {
                    $required_by[] = $info['name'];
                }
            }
        }

        if (empty($required_by)) {
            return true;
        }

        throw new UnexpectedValueException($this->translation->text('Required by') . ': ' . implode(', ', $required_by));
    }
221509
public function all(bool $include_disabled = false): Collection
    {
        return app('cache.array')->rememberForever('all_modules', function (): Collection {
            // Modules have a default status, order etc.
            // We can override these from database settings.
            $module_info = DB::table('module')
                ->get()
                ->mapWithKeys(static function (stdClass $row): array {
                    return [$row->module_name => $row];
                });

            return $this->coreModules()
                ->merge($this->customModules())
                ->map(static function (ModuleInterface $module) use ($module_info): ModuleInterface {
                    $info = $module_info->get($module->name());

                    if ($info instanceof stdClass) {
                        $module->setEnabled($info->status === 'enabled');

                        if ($module instanceof ModuleFooterInterface && $info->footer_order !== null) {
                            $module->setFooterOrder((int) $info->footer_order);
                        }

                        if ($module instanceof ModuleMenuInterface && $info->menu_order !== null) {
                            $module->setMenuOrder((int) $info->menu_order);
                        }

                        if ($module instanceof ModuleSidebarInterface && $info->sidebar_order !== null) {
                            $module->setSidebarOrder((int) $info->sidebar_order);
                        }

                        if ($module instanceof ModuleTabInterface && $info->tab_order !== null) {
                            $module->setTabOrder((int) $info->tab_order);
                        }
                    } else {
                        $module->setEnabled($module->isEnabledByDefault());

                        DB::table('module')->insert([
                            'module_name' => $module->name(),
                            'status'      => $module->isEnabled() ? 'enabled' : 'disabled',
                        ]);
                    }

                    return $module;
                });
        })->filter($this->enabledFilter($include_disabled));
    }