Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tdr 22/get depencencies from composer #764

Merged
merged 32 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7955d9d
get dependencies from composer
Apr 6, 2020
424af5f
cache available packages
Apr 7, 2020
bc13f61
refactor manifest construct; fix manifest unit test
Apr 8, 2020
fc2737e
fix manifest unit test
Apr 8, 2020
ea5ede6
add composer info test
Apr 8, 2020
74554ae
reduce complexity of getAvailablePackagesStatic
Apr 9, 2020
59e7b4d
reduce compexity of \oat\oatbox\extension\Manifest::getDependencies
Apr 9, 2020
95c46af
fix tao installation
Apr 9, 2020
5958004
fix Manifest unit test
Apr 9, 2020
434a9df
do not load extensons recursively
Apr 9, 2020
85903c0
use ComposerInfo constants
Apr 10, 2020
72ae8a9
retrieve root path if constant is not defined
Apr 10, 2020
c4899df
merge develop
Apr 10, 2020
e4f3a41
set version from composer after upate of extension
Apr 16, 2020
fff9217
merge develop
Nov 18, 2020
fa282d2
fix composer.json file
Nov 23, 2020
60ebe32
Merge branch 'develop' of https://github.com/oat-sa/generis into TDR-…
Nov 23, 2020
403ff85
Merge branch 'develop' of https://github.com/oat-sa/generis into TDR-…
Jan 12, 2021
72b7e6a
switch to composer 2.0; fix ComposerInfo unit test
Jan 12, 2021
b1ba9f6
remove getPackageInfo method
Jan 12, 2021
9e658ad
fix version retreival in manifest
Jan 12, 2021
85812fb
fix checks extractor
Jan 12, 2021
d3be5c1
Merge branch 'develop' of https://github.com/oat-sa/generis into TDR-…
Jan 12, 2021
ccc60b5
reduce complecity of getAvailablePackagesStatic
Jan 12, 2021
5688cbc
remove unused methods from minifest class
Jan 13, 2021
ed705b9
Merge branch 'develop' of https://github.com/oat-sa/generis into TDR-…
Jan 15, 2021
8f3e7a8
move extracting dependencies to ComposerInfo
Jan 15, 2021
957daff
update CompoerInfor unit test
Jan 15, 2021
316d716
remove static call in extension manager
Jan 19, 2021
4ade9d4
gix gitignore file
Jan 21, 2021
4a37523
Merge branch 'develop' of https://github.com/oat-sa/generis into TDR-…
Feb 10, 2021
2198028
feat!: get dependencies from composer file
Feb 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
/.settings/
/.buildpath
/data/*
composer.lock
/composer.lock
vendor/
.idea/
71 changes: 16 additions & 55 deletions common/ext/class.Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
*
*/

use common_ext_ManifestException as ManifestException;
use oat\oatbox\extension\exception\ManifestException;
use common_ext_UpdaterNotFoundException as UpdaterNotFoundException;
use oat\oatbox\service\ServiceManagerAwareInterface;
use oat\oatbox\service\ServiceManagerAwareTrait;
use oat\oatbox\service\ServiceNotFoundException;
use oat\oatbox\service\ConfigurableService;
use oat\oatbox\config\ConfigurationService;
use oat\oatbox\extension\exception\ManifestNotFoundException;
use oat\oatbox\extension\Manifest;

/**
* Short description of class common_ext_Extension
Expand Down Expand Up @@ -67,7 +69,7 @@ class common_ext_Extension implements ServiceManagerAwareInterface
/**
* The manifest of the extension
*
* @var common_ext_Manifest
* @var Manifest
*/
protected $manifest;

Expand Down Expand Up @@ -370,68 +372,28 @@ public function getDependencies()
/**
* Returns the manifest of the extension
*
* @return common_ext_Manifest
* @throws common_ext_ManifestNotFoundException
* @return Manifest
* @throws ManifestNotFoundException
*/
public function getManifest()
{
if (! $this->manifest) {
$manifestFile = $this->getDir() . self::MANIFEST_NAME;
if (is_file($manifestFile) && is_readable($manifestFile)) {
$this->manifest = new common_ext_Manifest($manifestFile);
$this->manifest = new Manifest($manifestFile);
} else {
throw new common_ext_ManifestNotFoundException("Extension Manifest not found for extension '" . $this->id . "'.", $this->id);
throw new ManifestNotFoundException("Extension Manifest not found for extension '" . $this->id . "'.", $this->id);
}
}
$this->manifest->setServiceLocator($this->getServiceLocator());
return $this->manifest;
}

/**
* Get the Management Role of the Extension. Returns null in case of no
* Role for the Extension.
*
* Removing all generis references from framework, please use the Manifest::getManagementRoleUri()
*
* @access public
* @author firstname and lastname of author, <author@example.org>
* @return core_kernel_classes_Resource
* @deprecated
* @see common_ext_Manifest::getManagementRoleUri()
*/
public function getManagementRole()
{
return $this->getManifest()->getManagementRole();
}

/**
* Get an array of Class URIs (as strings) that are considered optimizable by the Extension.
*
* @access public
* @author Jerome Bogaerts <jerome@taotesting.com>
* @return array
*/
public function getOptimizableClasses()
{
return $this->getManifest()->getOptimizableClasses();
}

public function getPhpNamespace()
{
return $this->getManifest()->getPhpNamespace();
}

/**
* Get an array of Property URIs (as strings) that are considered optimizable by the Extension.
*
* @access public
* @author Jerome Bogaerts <jerome@taotesting.com>
* @return array
*/
public function getOptimizableProperties()
{
return $this->getManifest()->getOptimizableProperties();
}

/**
* Whenever or not the extension and it's constants have been loaded
* @return boolean
Expand All @@ -448,14 +410,13 @@ public function isLoaded()
public function load()
{
if (!$this->isLoaded()) {
$dependencies = $this->getManifest()->getDependencies();
foreach ($dependencies as $extId => $extVersion) {
// triggers loading of extensions
try {
try {
$dependencies = $this->getManifest()->getDependencies();
foreach ($dependencies as $extId => $extVersion) {
$this->getExtensionManager()->getExtensionById($extId);
} catch (common_ext_ManifestNotFoundException $e) {
throw new common_ext_MissingExtensionException($e->getExtensionId() . ' not found but required for ' . $this->getId(), $e->getExtensionId());
}
} catch (ManifestNotFoundException $e) {
throw new common_ext_MissingExtensionException($e->getExtensionId() . ' not found but required for ' . $this->getId(), $e->getExtensionId());
}

$loader = new common_ext_ExtensionLoader($this);
Expand Down Expand Up @@ -497,8 +458,8 @@ public function getConfigHeader($key)
}

/**
* @throws common_ext_ManifestException
* @throws common_ext_ManifestNotFoundException
* @throws ManifestException
* @throws ManifestNotFoundException
* @throws common_ext_UpdaterNotFoundException
*/
public function getUpdater(): common_ext_ExtensionUpdater
Expand Down
3 changes: 2 additions & 1 deletion common/ext/class.ExtensionInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use oat\oatbox\service\ConfigurableService;
use oat\generis\model\data\import\RdfImporter;
use oat\oatbox\cache\SimpleCache;
use oat\oatbox\extension\exception\ManifestNotFoundException;

/**
* Generis installer of extensions
Expand Down Expand Up @@ -184,7 +185,7 @@ protected function installRegisterExt()
* Executes custom install scripts specified in the Manifest
*
* @throws common_ext_InstallationException
* @throws common_ext_ManifestNotFoundException
* @throws ManifestNotFoundException
*/
protected function installCustomScript()
{
Expand Down
3 changes: 2 additions & 1 deletion common/ext/class.ExtensionUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public function setVersion($version)
*/
public function isVersion($version)
{
return $version == common_ext_ExtensionsManager::singleton()->getInstalledVersion($this->getExtension()->getId());
$extensionsManager = $this->getServiceManager()->get(common_ext_ExtensionsManager::SERVICE_ID);
return $version == $extensionsManager->getInstalledVersion($this->getExtension()->getId());
}

/**
Expand Down
34 changes: 29 additions & 5 deletions common/ext/class.ExtensionsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

use oat\oatbox\service\ConfigurableService;
use oat\oatbox\service\ServiceManager;
use oat\oatbox\extension\exception\ManifestException;
use oat\oatbox\extension\ComposerInfo;
use oat\oatbox\cache\SimpleCache;

/**
* The ExtensionsManager class is dedicated to Extensions Management. It provides
Expand All @@ -33,7 +36,6 @@
* @authorlionel@taotesting.com
* @package generis
* @see @license GNU General Public (GPL) Version 2 http://www.opensource.org/licenses/gpl-2.0.php

*/
class common_ext_ExtensionsManager extends ConfigurableService
{
Expand Down Expand Up @@ -179,7 +181,7 @@ public function getExtensionById($id)
throw new common_ext_ExtensionException('No id specified for getExtensionById()');
}
if (! isset($this->extensions[$id])) {
$extension = new common_ext_Extension($id, false);
$extension = new common_ext_Extension($id);
$this->propagate($extension);

// loads the extension if it hasn't been loaded yet
Expand Down Expand Up @@ -218,7 +220,7 @@ public function setEnabled($extensionId, $enabled = true)
$exts[$extensionId]['enabled'] = (bool) $enabled;
return $this->getExtensionById('generis')->setConfig(self::EXTENSIONS_CONFIG_KEY, $exts);
}

/**
* Get the set of currently enabled extensions. This method
* returns an array of common_ext_Extension.
Expand All @@ -237,10 +239,10 @@ public function getEnabledExtensions()
$returnValue[$ext->getId()] = $ext;
}
}

return (array) $returnValue;
}

/**
* Add the end of an installation register the new extension
*
Expand Down Expand Up @@ -281,4 +283,26 @@ public function updateVersion(common_ext_Extension $extension, $version)
$extensions[$extension->getId()]['installed'] = $version;
$this->getExtensionById('generis')->setConfig(self::EXTENSIONS_CONFIG_KEY, $extensions);
}

/**
* Call a service to retrieve a map array of all available extensions
* with extension package id as a key and extension id as a value
* @return array
*/
public function getAvailablePackages()
{
$composer = new ComposerInfo();
//During installation list of packages is needed but cache service is not installed yet.
if (!$this->getServiceManager()->has(SimpleCache::SERVICE_ID)) {
return $composer->getAvailableTaoExtensions();
}
/** @var SimpleCache $cache */
$cache = $this->getServiceManager()->get(SimpleCache::SERVICE_ID);
$key = static::class.'_'.__METHOD__;
if (!$cache->has($key)) {
$cache->set($key, $composer->getAvailableTaoExtensions());
}

return (array) $cache->get($key);
}
}
3 changes: 2 additions & 1 deletion common/ext/class.GenerisInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use oat\generis\persistence\PersistenceManager;
use oat\generis\model\data\Ontology;
use oat\generis\persistence\sql\SchemaProviderInterface;
use oat\oatbox\extension\exception\ManifestNotFoundException;
use oat\oatbox\cache\SimpleCache;

/**
Expand All @@ -42,7 +43,7 @@ class common_ext_GenerisInstaller extends common_ext_ExtensionInstaller
* @throws common_Exception
* @throws common_ext_ExtensionException
* @throws common_ext_InstallationException
* @throws common_ext_ManifestNotFoundException
* @throws ManifestNotFoundException
*/
public function install()
{
Expand Down
Loading