src/Service/MelisCoreModulesService.php
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;
    }
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;
    }
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 ; }
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
Returns the dependencies of the module