Checks all modules for conflicting module names, and returns modules per
duplicate set.

@return array
16152
protected function checkForDuplicateNames()
    {
        $normalized = [];

        foreach ($this->data->rawData['modules'] as $moduleId => $module) {
            $normalized[ $moduleId ] = $this->normalizeName(
                array_get($module, 'prefixed_name') ?: $module['name']
            );
        }

        return $this->getKeysForDuplicates($normalized);
    }
194096
public static function getModuleNames(Args $args, ModuleList $modules)
    {
        // Display all modules if "all" is set
        if ($args->isOptionSet('all')) {
            return $modules->getModuleNames();
        }

        $moduleNames = array();

        if ($args->isOptionSet('root')) {
            $moduleNames[] = $modules->getRootModuleName();
        }

        foreach ($args->getOption('module') as $moduleName) {
            $moduleNames[] = $moduleName;
        }

        return $moduleNames ?: $modules->getModuleNames();
    }
712739
public function getSortedNames()
    {
        $sorted = [];
        $toSort = $this->getDependencies();

        while (count($toSort) > 0) {
            foreach ($toSort as $name => $dependencies) {
                if (!array_diff($dependencies, $sorted)) {
                    $sorted[] = $name;
                    unset($toSort[$name]);
                }
            }
        }

        return $sorted;
    }
979505
def compare(all_dict, others, names, module_name):
    """"""
    only_all = set()
    for name in all_dict:
        if name not in names:
            only_all.add(name)

    only_ref = set()
    missing = set()
    for name in names:
        if name not in all_dict:
            for pat in REFGUIDE_ALL_SKIPLIST:
                if re.match(pat, module_name + '.' + name):
                    if name not in others:
                        missing.add(name)
                    break
            else:
                only_ref.add(name)

    return only_all, only_ref, missing
670620
public function findForActiveModules()
    {
        $fs = new Filesystem();

        $codes = $this->queryActiveModuleCodes();

        foreach ($codes as $key => $code) {
            // test if the module exists on the file system
            if (!$fs->exists(THELIA_MODULE_DIR . $code)) {
                unset($codes[$key]);
            }
        }

        // reset keys
        $codes = array_values($codes);

        return $this->findForModules($codes);
    }
152302
private function getPathsOfAvailableModules()
    {
        $config = Registry::getConfig();
        $modulesRootPath = $config->getModulesDir();
        $modulePaths = $config->getConfigParam('aModulePaths');

        if (!is_dir($modulesRootPath))
            return [];

        if (!is_array($modulePaths))
            return [];

        $fullModulePaths = array_map(function ($modulePath) use ($modulesRootPath) {
            return $modulesRootPath . $modulePath;
        }, array_values($modulePaths));

        return array_filter($fullModulePaths, function ($fullModulePath) {
            return is_dir($fullModulePath);
        });
    }
1184551
public function getModulesIndex()
    {
        if ($this->modulesIndex) {
            return $this->modulesIndex;
        }

        $modules = $this->getModuleManager()->getModules();

        $modulesIndex = [];

        foreach ($modules as $moduleName) {
            $prepareModuleName = rtrim($moduleName, '\\') . '\\';
            $modulesIndex[$prepareModuleName] = strlen($prepareModuleName);
        }

        arsort($modulesIndex, SORT_NUMERIC);
        $this->modulesIndex = $modulesIndex;

        return $this->modulesIndex;
    }
1026089
public function getUpdates()
    {
        if (!$this->loadRepositories()) {
            return Repository::STATUS_NO_REPOSITORIES;
        }

        $modules = $this->getModulesFromRepository();

        // Is a higher version of an already installed package available?
        foreach ($modules as $key => $module) {
            $version = $this->packageService->getVersion($module->name);

            if (!$version) {
                // Not installed at all.
                unset($modules[$key]);
            } elseif (version_compare($version, $module->version, '<')) {
                // Older version installed.
                $modules[$key]->versionInstalled = $version;
            } else {
                unset($modules[$key]);
            }
        }

        return $modules;
    }
1086026
protected function get_module_names() {
        if ($this->_modnames !== null) {
            return $this->_modnames;
        }
        $this->_modnames = [];
        foreach ($this->modules as $module) {
            $this->_modnames[$module->name] = $module->formattedname;
        }
        return $this->_modnames;
    }
1017369
protected function getTypesModule()
    {
        $types = array();

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

        return $types;
    }
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;
    }
203768
protected function getConflicts($entitiesByModule)
    {
        $modules = array_keys($entitiesByModule);
        $allConflicts = array();
        // bubble-compare each group of modules
        for ($i = 0; $i < count($modules) - 1; $i++) {
            $left = array_keys($entitiesByModule[$modules[$i]]);
            for ($j = $i+1; $j < count($modules); $j++) {
                $right = array_keys($entitiesByModule[$modules[$j]]);
                $conflicts = array_intersect($left, $right);
                $allConflicts = array_merge($allConflicts, $conflicts);
            }
        }
        return array_unique($allConflicts);
    }
987504
public function getAllModularInfo()
    {
        $modularInfo = new Collection();
        foreach ($this->getAllValidModular() as $modularName => $modular) {
            $modularInfo[$modularName] = $this->getModularInformation($modularName);
        }

        return $modularInfo;
    }
1053640
private function getDuplicates(): array
  {
    // First pass make lookup table by method_name.
    $lookup = [];
    foreach ($this->sources as $source)
    {
      if (isset($source['method_name']))
      {
        if (!isset($lookup[$source['method_name']]))
        {
          $lookup[$source['method_name']] = [];
        }

        $lookup[$source['method_name']][] = $source;
      }
    }

    // Second pass find duplicate sources.
    $duplicates_sources = [];
    $duplicates_methods = [];
    foreach ($this->sources as $source)
    {
      if (sizeof($lookup[$source['method_name']])>1)
      {
        $duplicates_sources[$source['path_name']]   = $source;
        $duplicates_methods[$source['method_name']] = $lookup[$source['method_name']];
      }
    }

    return [$duplicates_sources, $duplicates_methods];
  }
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;
    }
238485
protected function get_module_name_plural() {
        if (isset(self::$modulenameplural)) {
            return self::$modulenameplural;
        }
        self::$modulenameplural = get_string('modulenameplural', 'assign');
        return self::$modulenameplural;
    }
1142167
public static function cleanModuleList($modules)
    {
        $app = \JFactory::getApplication();

        // Apply negative selections and eliminate duplicates
        $Itemid = \JFactory::getApplication()->input->getInt('Itemid');
        $negId = $Itemid ? -(int) $Itemid : false;
        $clean = array();
        $dupes = array();

        foreach ($modules as $i => $module)
        {
            // The module is excluded if there is an explicit prohibition
            $negHit = ($negId === (int) $module->menuid);

            if (isset($dupes[$module->id]))
            {
                // If this item has been excluded, keep the duplicate flag set,
                // but remove any item from the modules array.
                if ($negHit)
                {
                    unset($clean[$module->id]);
                }

                continue;
            }

            $dupes[$module->id] = true;

            // Only accept modules without explicit exclusions.
            if ($negHit)
            {
                continue;
            }

            $module->name = substr($module->module, 4);
            $module->style = null;
            $module->position = strtolower($module->position);

            $clean[$module->id] = $module;
        }

        unset($dupes);

        // Do 3rd party stuff to manipulate module array.
        // Any plugins using this architecture may make alterations to the referenced $modules array.
        // To remove items you can do unset($modules[n]) or $modules[n]->published = false.

        // "onPrepareModuleList" may alter or add $modules, and does not need to return anything.
        // This should be used for module addition/deletion that the user would expect to happen at an
        // early stage.
        $app->triggerEvent( 'onPrepareModuleList', array( &$clean ) );

        // "onAlterModuleList" may alter or add $modules, and does not need to return anything.
        $app->triggerEvent( 'onAlterModuleList', array( &$clean ) );

        // "onPostProcessModuleList" allows a plugin to perform actions like parameter changes
        // on the completed list of modules and is guaranteed to occur *after*
        // the earlier plugins.
        $app->triggerEvent( 'onPostProcessModuleList', array( &$clean ) );

        // Remove any that were marked as disabled during the preceding steps
        /*foreach ( $clean as $id => $module )
        {
            if ( !isset( $module->published ) || $module->published == 0 )
            {
                unset( $clean[$id] );
            }
        }*/

        // Return to simple indexing that matches the query order.
        return array_values($clean);
    }