Call a service to retrieve list of extensions that may be installed.
This method returns an array of common_ext_Extension.

@access public
@author Joel Bout, <joel@taotesting.com>
@return array
349918
public function getAvailableExtensions()
    {
        $returnValue = array();
		$dir = new DirectoryIterator(ROOT_PATH);
		foreach ($dir as $fileinfo) {
			if ($fileinfo->isDir() && !$fileinfo->isDot() && substr($fileinfo->getBasename(), 0, 1) != '.') {
				$extId = $fileinfo->getBasename();
				if (!in_array($extId, self::$RESERVED_WORDS) && !$this->isInstalled($extId)) {
    				try {
    					$ext = $this->getExtensionById($extId);
    					$returnValue[] = $ext;
    				} catch (common_ext_ExtensionException $exception) {
    					common_Logger::d($extId.' is not an extension');
    				}
				}
			}
		}
		
		return $returnValue;
    }
880944
public function loadExtensions()
    {
		foreach($this->extensions as $extension) {
			//handle dependances requirement
			foreach ($extension->getManifest()->getDependencies() as $ext => $version) {
				if(!array_key_exists($ext, $this->extensions) && $ext != 'generis') {
					throw new common_ext_ExtensionException('Required Extension is Missing : ' . $ext);
				}
			}
			$extension->load();
		}
    }
799429
protected function getMediaSources()
    {
        if (is_null($this->mediaSources)) {
            $this->mediaSources = array();
            
            $tao = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao');
            $sources = $tao->getConfig(self::CONFIG_KEY);
            $sources = is_array($sources) ? $sources : array();
            
            foreach($sources as $mediaSourceId => $mediaSource){
                $this->mediaSources[$mediaSourceId] = is_object($mediaSource)
                    ? $mediaSource
                    : new $mediaSource(array());
            }
        }
        return $this->mediaSources;
    }
379124
public function load()
    {
        if (!$this->isLoaded()) {
            $dependencies = $this->getManifest()->getDependencies();
            foreach ($dependencies as $extId => $extVersion) {
                // triggers loading of extensions
                try {
                    $this->getExtensionManager()->getExtensionById($extId);
                } catch (common_ext_ManifestNotFoundException $e) {
                    throw new common_ext_MissingExtensionException($e->getExtensionId().' not found but required for '.$this->getId());
                }
            }
            
            $loader = new common_ext_ExtensionLoader($this);
            $loader->load();
            //load all dependent extensions
            $this->loaded = true;
        }
    }
230360
public static function findExtensionsFiles($fileName = 'config/main.php') : array
    {
        $output     = [];
        $fileNames  = !is_array($fileName) ? [$fileName] : $fileName;
        if (empty(static::$extensions)) {
            static::$extensions = (array) require Yii::getAlias('@root/vendor/yiisoft/extensions.php');
        }
        foreach (static::$extensions as $ext => $data) {
            if (is_array($data['alias'])) {
                foreach ($data['alias'] as $alias => $path) {
                    foreach ($fileNames as $fileName) {
                        $file = $path . '/' .$fileName;
                        if ((strpos($ext, 'setrun') !== false) && file_exists($file)) {
                            $output[] = $file;
                        }
                    }
                }
            }
        }
        return $output;
    }
834035
public function registerExtension(common_ext_Extension $extension)
    {
        $entry = array(
        	'installed' => $extension->getManifest()->getVersion(),
            'enabled' => false 
        );
        $extensions = $this->getExtensionById('generis')->getConfig(self::EXTENSIONS_CONFIG_KEY);
        $extensions[$extension->getId()] = $entry;
        return $this->getExtensionById('generis')->setConfig(self::EXTENSIONS_CONFIG_KEY, $extensions);
    }
420697
public function actionInstall()
    {
       
        $extensionId = $this->options['extension']; // ID of the extension to install.
        $importLocalData = $this->options['data']; // Import local data (local.rdf) or not ?
        try{
            // Retrieve the extension's information.
            $this->outVerbose("Locating extension '${extensionId}'...");
            $extensionManager = common_ext_ExtensionsManager::singleton();
            $ext = $extensionManager->getExtensionById($extensionId);
            $this->outVerbose("Extension located.");
            
            try{
                // Install the extension.
                $this->outVerbose("Installing extension '${extensionId}'...");
                $installer = new tao_install_ExtensionInstaller($ext, $importLocalData);
                $installer->install();
                $this->outVerbose("Extension successfully installed.");
            }
            catch (common_ext_ForbiddenActionException $e){
                $this->error("A forbidden action was undertaken: " . $e->getMessage() . " .", true);
            }
            catch (common_ext_AlreadyInstalledException $e){
                $this->error("Extension '" . $e->getExtensionId() . "' is already installed.", true);
            }
            catch (common_ext_MissingExtensionException $e){
                $this->error("Extension '" . $extensionId . " is dependant on extension '" . $e->getExtensionId() . "' but is missing. Install '" . $e->getExtensionId() . "' first.", true);
            }
        }
        catch (common_ext_ExtensionException $e){
            $this->error("An unexpected error occured: " . $e->getMessage(), true);
        }
      
    }
787451
private function loadExtensions()
    {
        $this->getServiceLocator()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoOutcomeUi');
        $this->getServiceLocator()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoDeliveryRdf');
    }
1167214
public function getExtensions()
    {
        $data = [];
        foreach (\Yii::$app->extensions as $extension) {
            $data[$extension['name']] = $extension['version'];
        }

        return $data;
    }
307530
public function getExtensionsInfoList()
    {
        $data = json_decode(
            $this->getRemoteContents($this->extensionsInfofoUrl)
        );

        $content = $data->encoding === 'base64' ? base64_decode($data->content) : [];
        return json_decode($content, true);// true to array
    }
3019
private function resolveObjectExtensions(HasExtensionsInterface $objectDefinition): array
    {
        $extensions = [];

        //get all extensions registered as services
        $registeredExtensions = $this->container->get(ExtensionManager::class)->getExtensions();
        foreach ($registeredExtensions as $registeredExtension) {
            foreach ($objectDefinition->getExtensions() as $extensionDefinition) {
                $extensionClass = $extensionDefinition->getClass();
                if (\get_class($registeredExtension) === $extensionClass) {
                    $extensions[$extensionClass] = $registeredExtension;
                }
            }
        }

        //get all extensions not registered as services
        foreach ($objectDefinition->getExtensions() as $extensionDefinition) {
            $class = $extensionDefinition->getClass();
            if (!isset($extensions[$class])) {
                $instance = new $class();
                if ($instance instanceof ContainerAwareInterface) {
                    $instance->setContainer($this->container);
                }

                $extensions[$class] = $instance;
            }
        }

        return array_values($extensions);
    }
1165921
public function getExtensions()
    {
        $data = [];
        foreach ($this->data['extensions'] as $extension) {
            $data[$extension['name']] = $extension['version'];
        }
        ksort($data);

        return $data;
    }
1162757
public function getAvailableExtensions(): Extensions
    {
        if ($this->availableExtensions instanceof Extensions) {
            return $this->availableExtensions;
        }
        $foundExtensions  = $this->filesystemFinder->findExtensions();
        $storedExtensions = app('antares.installed') ? $this->extensionsRepository->all() : new Collection();

        foreach ($foundExtensions as $foundExtension) {
            $extension = $storedExtensions->first(function(ExtensionModel $extensionModel) use($foundExtension) {
                return $extensionModel->getFullName() === $foundExtension->getPackage()->getName();
            });

            $configFile = $foundExtension->getPath() . '/resources/config/settings.php';

            if ($this->filesystem->exists($configFile)) {
                $foundExtension->setSettings($this->settingsFactory->createFromConfig($configFile));
            }

            if ($extension instanceof ExtensionModel) {
                $foundExtension->setStatus($extension->getStatus());
                $foundExtension->setIsRequired($extension->isRequired());
                $foundExtension->getSettings()->updateData($extension->getOptions());
            }
        }

        return $this->availableExtensions = $foundExtensions;
    }
720011
public static function getUsedExtensionList()
    {
        $app = Application::getFacadeApplication();
        $db = $app->make('database')->connection();
        $stm = $db->executeQuery("select distinct fvExtension from FileVersions where fvIsApproved = 1 and fvExtension is not null and fvExtension <> ''");
        $extensions = [];
        while ($row = $stm->fetch()) {
            $extensions[] = $row['fvExtension'];
        }

        return $extensions;
    }
298992
public static function getAllowedExtensions()
    {
        $config = static::config()->get('allowed_extensions');

        $allowedExtensions = [];
        foreach ($config as $key => $value) {
            if (is_int($key)) {
                // Numeric indexes, example: [jpg, png, gif]
                $key = $value;
                $value = true;
            }

            // Skip disabled extensions
            if (in_array($value, [null, false], true)) {
                continue;
            }

            $allowedExtensions[] = strtolower($key);
        }
        return $allowedExtensions;
    }
394375
public static function getAll()
    {
        $class = get_called_class();
        
        if (!isset(self::$instance[$class])) {
            self::$instance[$class] = new static();
        }
        
        return self::$instance[$class]->getExtensions();
    }
862438
public function get_extensions()
    {
        if ($this->exts)
            return $this->exts;

        if (!$this->sieve)
            return $this->_set_error(self::ERROR_INTERNAL);

        $ext = $this->sieve->getExtensions();

        if (is_a($ext, 'PEAR_Error')) {
            return array();
        }

        // we're working on lower-cased names
        $ext = array_map('strtolower', (array) $ext);

        if ($this->script) {
            $supported = $this->script->get_extensions();
            foreach ($ext as $idx => $ext_name)
                if (!in_array($ext_name, $supported))
                    unset($ext[$idx]);
        }

        return array_values($ext);
    }