Returns the dependencies of the module

@param $moduleName
@param bool $convertPackageNameToNamespace - set to "true" to convert all package name into their actual Module name

@return array
760750
public function getDependencies($moduleName, $convertPackageNameToNamespace = true)
    {
        $modulePath = $this->getModulePath($moduleName);
        $dependencies = [];

        if ($modulePath) {

            $defaultDependencies = ['melis-core'];
            $dependencies = $defaultDependencies;
            $composerPossiblePath = [$modulePath . '/composer.json'];
            $composerFile = null;

            // search for the composer.json file
            foreach ($composerPossiblePath as $file) {
                if (file_exists($file)) {
                    $composerFile = file_get_contents($file);
                }
            }

            // if composer.json is found
            if ($composerFile) {

                $composer = json_decode($composerFile, true);
                $requires = isset($composer['require']) ? $composer['require'] : null;
                if ($requires) {
                    $requires = array_map(function ($a) {
                        // remove melisplatform prefix
                        return str_replace(['melisplatform/', ' '], '', trim($a));
                    }, array_keys($requires));

                    $dependencies = $requires;
                }
            }

            if ($convertPackageNameToNamespace) {
                $tmpDependencies = [];
                $toolSvc = $this->getServiceLocator()->get('MelisCoreTool');

                foreach ($dependencies as $dependency) {
                    $tmpDependencies[] = ucfirst($toolSvc->convertToNormalFunction($dependency));
                }

                $dependencies = $tmpDependencies;
            }
        }

        return $dependencies;
    }
710191
public static function getInstance($dependencyName, array $loadedDependencies)
    {
        $k = $dependencyName . '_' . implode('_', $loadedDependencies);
        if (!isset(self::$_instances[$k])) {
            self::$_instances[$k] = new self(Kwf_Assets_Package_Default::getDefaultProviderList(), $dependencyName, $loadedDependencies);
        }
        return self::$_instances[$k];
    }
1131863
public function getFlattenedRequiredPackages()
    {
        $result = [];
        foreach ($this->getRequiredPackages() as $dependency) {
            $name          = $dependency->getPackage()->getName();
            $result[$name] = $dependency;
            $result        = array_merge($result, $dependency->getFlattenedRequiredPackages());
        }
        return $result;
    }
1368572
protected function getPackage($packageName)
    {
        try {
            $package = $this->packagist->get($packageName);
            $this->getOutput()->writeln(sprintf(
                'Package to install: <info>%s</info> (%s)',
                $package->getName(),
                $package->getDescription()
            ));
            $this->requirePackage($package);
        } catch (ClientErrorResponseException $e) {
            $this->searchPackage($packageName);
        }
    }
136542
public function getOpponents($moduleName)
    {
        if (!isset($this->moduleNames[$moduleName])) {
            return array();
        }

        $opponents = $this->moduleNames;

        unset($opponents[$moduleName]);

        return array_keys($opponents);
    }
208201
public function getModule($moduleName)
    {
        if (!$this->hasModule($moduleName)) {
            throw new ModuleException(__CLASS__, "Module $moduleName couldn't be connected");
        }

        return $this->modules[$moduleName];
    }
237409
protected function getBaseNamespace()
    {
        if ($this->packageInfo->get('type') == 'module') {
            return $this->packages->getModulesNamespace();
        }

        return $this->packages->getPackagesNamespace();
    }
1303651
public function getDependencies()
    {
        // Simple cache.
        if (is_array($this->dependencies)) {
            return $this->dependencies;
        }
        $this->dependencies = [];

        $filter = new StatementFilter();
        $parser = new CodeParser();

        $statements = $parser->parseFile($this->directory.'/version.php');

        try {
            $assign = $filter->findFirstPropertyFetchAssignment($statements, 'plugin', 'dependencies');
        } catch (\Exception $e) {
            try {
                $assign = $filter->findFirstPropertyFetchAssignment($statements, 'module', 'dependencies');
            } catch (\Exception $e) {
                return $this->dependencies;
            }
        }

        if (!$assign->expr instanceof Array_) {
            throw new \RuntimeException('The $plugin->dependencies must be assigned to an array in the version.php file.');
        }
        $this->dependencies = $filter->arrayStringKeys($assign->expr);

        return $this->dependencies;
    }
133117
public function getPayload($module, $methodName)
    {
        $payloads = array();

        $config = $this->getServiceLocator()->get('MelisCoreConfig');
        $payloads = $config->getItem('diagnostic/'.$module.'/methods/'. $this->getMethodName($methodName) .'/payloads');

        return $payloads;

    }
1110158
public static function moduleClass($moduleName = 'Module')
    {
        $result = false;

        $className = get_called_class();
        $refClass = new ReflectionClass($className);
        $ns = $refClass->getNamespaceName();

        $len = strlen($ns) - strlen(UniModule::$modelsSubdir);
        if (strrpos($ns, UniModule::$modelsSubdir) == $len) {
           $ns = substr($ns, 0, $len);
           $result = $ns . $moduleName;
        }

        return $result;
    }
129051
public function getOptionsByModuleName($moduleName)
    {
        $moduleOptions = $this->resolveModuleOptionsByModuleName($moduleName);
        $this->validatePlugin($moduleOptions);

        return $moduleOptions;
    }
1297259
public function getThemes($moduleName)
    {
        $dir = $this->kernel->getBundle('SiteBundle')->getPath().'/Resources/modules/'.$moduleName;

        if (!is_dir($dir)) {
            return [];
        }

        $finder = new Finder();
        $finder->directories()->sortByName()->depth('== 0')->in($dir);

        $themes = [];
        /** @var \Symfony\Component\Finder\SplFileInfo $file */
        foreach ($finder as $file) {
            $themes[] = $file->getFilename();
        }

        return $themes;
    }
185205
private static BundleCapability getExportedPackage(BundleContext context, String packageName) {
        List<BundleCapability> packages = new ArrayList<BundleCapability>();
        for (Bundle bundle : context.getBundles()) {
            BundleRevision bundleRevision = bundle.adapt(BundleRevision.class);
            for (BundleCapability packageCapability : bundleRevision.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE)) {
                String pName = (String) packageCapability.getAttributes().get(BundleRevision.PACKAGE_NAMESPACE);
                if (pName.equalsIgnoreCase(packageName)) {
                    packages.add(packageCapability);
                }
            }
        }

        Version max = Version.emptyVersion;
        BundleCapability maxVersion = null;
        for (BundleCapability aPackage : packages) {
            Version version = (Version) aPackage.getAttributes().get("version");
            if (max.compareTo(version) <= 0) {
                max = version;
                maxVersion = aPackage;
            }
        }

        return maxVersion;
    }
1152550
final protected static function checkDependencies(string $dependencyClassName, string $dependencyPackageName)
    {
        if (!class_exists($dependencyClassName)) {
            throw new MissingDependencyException(
                sprintf(
                    'Class "%s" does not exist, please install package "%s"',
                    $dependencyClassName,
                    $dependencyPackageName
                )
            );
        }
    }
948908
protected function resolveDependencies(): array
    {
        $dependencies = [];
        $modules = $this->manager->modules();

        foreach ($this->package()->getRequires() as $dependency) {
            $target = $dependency->getTarget();
            if (isset($modules[$target])) {
                $dependencies[$target] = $modules[$target];
            }
        }

        return $dependencies;
    }
120707
public static function getDependenciesFor($className, $createAll = false)
    {
        try {
            $reflection = new \ReflectionClass($className);
        } catch (\Exception $e) {
            $message = "Could not create instance of '{$className}'";
            throw new \Parable\DI\Exception($message);
        }

        $construct = $reflection->getConstructor();

        if (!$construct) {
            return [];
        }

        $parameters = $construct->getParameters();

        $dependencies = [];
        foreach ($parameters as $parameter) {
            $subClassName = $parameter->name;

            try {
                $class = $parameter->getClass();
                if (is_object($class)) {
                    $subClassName = $class->name;
                }
            } catch (\ReflectionException $e) {
            }

            if ($createAll) {
                $dependencies[] = self::createAll($subClassName, $className);
            } else {
                $dependencies[] = self::get($subClassName, $className);
            }
        }
        return $dependencies;
    }
873565
public function getDependenciesFor(
        string $name,
        int $useStoredDependencies = self::USE_STORED_DEPENDENCIES
    ): array {
        $name = $this->getDefinitiveName($name);

        try {
            $reflection = new ReflectionClass($name);
        } catch (Throwable $e) {
            throw new ContainerException(sprintf(
                'Could not create instance for class `%s`.',
                $name
            ));
        }

        $constructor = $reflection->getConstructor();

        if (!$constructor) {
            return [];
        }

        $parameters = $constructor->getParameters();

        $relationships = [];
        $dependencies = [];
        foreach ($parameters as $parameter) {
            $class = $parameter->getClass();

            if ($class === null) {
                if (!$parameter->isOptional()) {
                    throw new ContainerException(sprintf(
                        'Cannot inject value for non-optional constructor parameter `$%s` without a default value.',
                        $parameter->name
                    ));
                }

                $dependencies[] = $parameter->getDefaultValue();

                continue;
            }

            $dependencyName = $this->getDefinitiveName($class->name);

            $this->storeRelationship($name, $dependencyName);

            $relationships[] = $dependencyName;

            if ($useStoredDependencies === self::USE_NEW_DEPENDENCIES) {
                $dependencies[] = $this->build($dependencyName);
            } elseif ($useStoredDependencies === self::USE_STORED_DEPENDENCIES) {
                $dependencies[] = $this->get($dependencyName);
            } else {
                throw new ContainerException(sprintf(
                    'Invalid dependency type value passed: `%d`.',
                    $useStoredDependencies
                ));
            }
        }

        return $dependencies;
    }