Skip to content

Commit

Permalink
Merge pull request #916 from oat-sa/release-15.3.0
Browse files Browse the repository at this point in the history
Release 15.3.0
  • Loading branch information
gabrielfs7 authored Sep 24, 2021
2 parents 1bfc5ba + 8896dc0 commit 6e6a515
Show file tree
Hide file tree
Showing 33 changed files with 1,931 additions and 37 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ generis
=======

Core extension, provide the low level framework and an API to manage ontologies

## Components

### Dependency Injection

Read here [how to use Dependency Injection](./core/DependencyInjection/README.md)
31 changes: 20 additions & 11 deletions common/oatbox/Configurable.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2014 (original work) Open Assessment Technologies SA;
*
* Copyright (c) 2014-2021 (original work) Open Assessment Technologies SA;
*/

namespace oat\oatbox;
Expand All @@ -31,24 +30,29 @@
* https://github.com/basdenooijer/solarium/blob/master/library/Solarium/Core/Configurable.php
*
* @author Joel Bout <[email protected]>
* @deprecated New services must be registered using Dependency Injection Container
*/
abstract class Configurable implements PhpSerializable, TaoLoggerAwareInterface
{
use LoggerAwareTrait;


/** @var array */
private $options = [];

/**
* public constructor to allow the object to be recreated from php code
*
* @param array $options
* @deprecated New services must be registered using Dependency Injection Container
*/
public function __construct($options = [])
{
$this->setOptions($options);
}

/**
* @deprecated Use \oat\generis\model\DependencyInjection\ServiceOptions instead
*/
public function setOption($name, $value)
{
$this->options[$name] = $value;
Expand All @@ -60,6 +64,7 @@ public function setOption($name, $value)
* @param array $options
* @return void
* @throws \common_exception_Error
* @deprecated Use \oat\generis\model\DependencyInjection\ServiceOptions instead
*/
public function setOptions(array $options)
{
Expand All @@ -72,12 +77,13 @@ public function setOptions(array $options)
}
$this->options = $options;
}

/**
* Returns whenever or not the option is defined
*
* @param string $name
* @return boolean
* @deprecated Use \oat\generis\model\DependencyInjection\ServiceOptions instead
*/
public function hasOption($name)
{
Expand All @@ -92,25 +98,28 @@ public function hasOption($name)
* @param string $name
* @param mixed|null $default Default value to return if option is not set.
* @return mixed
* @deprecated Use \oat\generis\model\DependencyInjection\ServiceOptions instead
*/
public function getOption($name, $default = null)
{
return $this->options[$name] ?? $default;
}

/**
* Get all options
*
* @return array

/**
* Get all options
*
* @return array
* @deprecated Use \oat\generis\model\DependencyInjection\ServiceOptions instead
*/
public function getOptions()
{
return $this->options;
}

/**
* (non-PHPdoc)
* @see \oat\oatbox\PhpSerializable::__toPhpCode()
* @deprecated Use \oat\generis\model\DependencyInjection\ServiceOptions instead
*/
public function __toPhpCode()
{
Expand Down
9 changes: 9 additions & 0 deletions common/oatbox/extension/Manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

namespace oat\oatbox\extension;

use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
use oat\oatbox\extension\exception\ManifestException;
use oat\oatbox\extension\exception\ManifestNotFoundException;
use oat\oatbox\service\exception\InvalidServiceManagerException;
Expand Down Expand Up @@ -256,6 +257,14 @@ public function getExtra()
return isset($this->manifest['extra']) ? $this->manifest['extra'] : [];
}

/**
* @return ContainerServiceProviderInterface[]
*/
public function getContainerServiceProvider(): array
{
return $this->manifest['containerServiceProviders'] ?? [];
}

/**
* Extract dependencies for extensions
* @param string $file
Expand Down
32 changes: 18 additions & 14 deletions common/oatbox/service/ConfigurableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,42 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2015 (original work) Open Assessment Technologies SA;
*
* Copyright (c) 2015-2021 (original work) Open Assessment Technologies SA;
*/

namespace oat\oatbox\service;


use oat\oatbox\Configurable;
use oat\oatbox\log\LoggerAwareTrait;
use oat\oatbox\service\exception\InvalidService;
use oat\oatbox\service\exception\InvalidServiceManagerException;
use Psr\Log\LoggerAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareInterface;


/**
* Configurable base service
*
* inspired by Solarium\Core\Configurable by Bas de Nooijer
* https://github.com/basdenooijer/solarium/blob/master/library/Solarium/Core/Configurable.php
*
* @author Joel Bout <[email protected]>
* @deprecated New services must be registered using Dependency Injection Container
*/
abstract class ConfigurableService extends Configurable implements ServiceLocatorAwareInterface
{
use ServiceManagerAwareTrait;

/** @var string Documentation header */


protected $header = null;

/** @var object[] */
private $subServices = [];

/**
* Get the service manager
*
* @deprecated Use $this->propagate instead
*
* @param $serviceManager
*/
* Get the service manager
*
* @deprecated Use $this->propagate instead
*
* @param $serviceManager
*/
public function setServiceManager($serviceManager)
{
$this->setServiceLocator($serviceManager);
Expand All @@ -65,6 +64,7 @@ public function setServiceManager($serviceManager)
* @return mixed
* @throws InvalidService
* @throws InvalidServiceManagerException
* @deprecated New services must be registered using Dependency Injection Container
*/
public function getSubService($id, $interface = null)
{
Expand All @@ -87,6 +87,7 @@ public function getSubService($id, $interface = null)
* Set the documentation header uses into config file
*
* @param $header
* @deprecated New services must be registered using Dependency Injection Container
*/
public function setHeader($header)
{
Expand All @@ -97,6 +98,7 @@ public function setHeader($header)
* Return the documentation header
*
* @return string
* @deprecated New services must be registered using Dependency Injection Container
*/
public function getHeader()
{
Expand All @@ -111,6 +113,7 @@ public function getHeader()
* Get the documentation header
*
* @return string
* @deprecated New services must be registered using Dependency Injection Container
*/
protected function getDefaultHeader()
{
Expand All @@ -128,6 +131,7 @@ protected function getDefaultHeader()
* @return mixed
* @throws InvalidService
* @throws InvalidServiceManagerException
* @deprecated New services must be registered using Dependency Injection Container
*/
protected function buildService($serviceDefinition, $interfaceName = null)
{
Expand Down
44 changes: 43 additions & 1 deletion common/oatbox/service/ServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2015 (original work) Open Assessment Technologies SA;
* Copyright (c) 2015-2021 (original work) Open Assessment Technologies SA;
*
*/

namespace oat\oatbox\service;

use oat\generis\model\DependencyInjection\ContainerBuilder;
use oat\generis\model\DependencyInjection\ContainerStarter;
use oat\oatbox\Configurable;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
Expand All @@ -34,6 +36,9 @@ class ServiceManager implements ServiceLocatorInterface, ContainerInterface
{
private static $instance;

/** @var ContainerStarter */
private $containerStarter;

/**
* @return \oat\oatbox\service\ServiceManager
* @deprecated Pass service locator instead of relying on static function
Expand Down Expand Up @@ -71,6 +76,7 @@ public function __construct($configService)
* @return ConfigurableService
* @throws ServiceNotFoundException
* @see ContainerInterface::get()
* @deprecated Use $this->getContainer()->get()
*/
public function get($serviceKey)
{
Expand Down Expand Up @@ -138,6 +144,7 @@ private function tryAutowiring($serviceId, $serviceKey)
/**
* (non-PHPdoc)
* @see ContainerInterface::has()
* @deprecated Use $this->getContainer()->has()
*/
public function has($serviceKey)
{
Expand All @@ -159,6 +166,7 @@ public function has($serviceKey)
* @param string $serviceKey
* @param ConfigurableService $service
* @throws \common_Exception
* @deprecated New services must be registered using Dependency Injection Container
*/
public function register($serviceKey, ConfigurableService $service)
{
Expand All @@ -174,6 +182,9 @@ public function register($serviceKey, ConfigurableService $service)
}
}

/**
* @deprecated New services must be registered using Dependency Injection Container
*/
public function unregister($serviceKey)
{
unset($this->services[$serviceKey]);
Expand All @@ -195,6 +206,7 @@ protected function getConfig()
* @return mixed
*
* @deprecated - If class uses ServiceManagerAwareTrait use $this->propagate($service)
* @deprecated New services must be registered using Dependency Injection Container
*/
public function propagate($service)
{
Expand All @@ -211,6 +223,7 @@ public function propagate($service)
* @param $className
* @param array $options
* @return mixed
* @deprecated New services must be registered using Dependency Injection Container
*/
public function build($className, array $options = [])
{
Expand All @@ -237,9 +250,38 @@ public function __sleep()
*
* @param $serviceKey
* @param ConfigurableService $service
* @deprecated New services must be registered using Dependency Injection Container
*/
public function overload($serviceKey, ConfigurableService $service)
{
$this->services[$serviceKey] = $service;
}

/**
* @TODO Container will be removed from here as soon as we do not need ServiceManager anymore.
*/
public function getContainer(): ContainerInterface
{
return $this->getContainerStarter()->getContainer();
}

/**
* @TODO ContainerBuilder will be removed from here as soon as we do not need ServiceManager anymore.
*/
public function getContainerBuilder(): ContainerBuilder
{
return $this->getContainerStarter()->getContainerBuilder();
}

/**
* @TODO ContainerStarter will be removed from here as soon as we do not need ServiceManager anymore.
*/
private function getContainerStarter(): ContainerStarter
{
if (!$this->containerStarter) {
$this->containerStarter = new ContainerStarter($this);
}

return $this->containerStarter;
}
}
8 changes: 5 additions & 3 deletions common/oatbox/service/ServiceManagerAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2014-2017 (original work) Open Assessment Technologies SA;
*
*
* Copyright (c) 2014-2021 (original work) Open Assessment Technologies SA;
*/

namespace oat\oatbox\service;
Expand All @@ -37,6 +35,7 @@
*
* @package oat\oatbox\service
* @author Moyon Camille
* @deprecated New services must be registered using Dependency Injection Container
*/
trait ServiceManagerAwareTrait
{
Expand All @@ -50,6 +49,7 @@ trait ServiceManagerAwareTrait
*
* @return ServiceManager
* @throws InvalidServiceManagerException
* @deprecated New services must be registered using Dependency Injection Container
*/
public function getServiceManager()
{
Expand All @@ -70,6 +70,7 @@ public function getServiceManager()
* @param ConfigurableService $service
* @param bool $allowOverride
* @throws \common_Exception
* @deprecated New services must be registered using Dependency Injection Container
*/
public function registerService($serviceKey, ConfigurableService $service, $allowOverride = true)
{
Expand All @@ -83,6 +84,7 @@ public function registerService($serviceKey, ConfigurableService $service, $allo
*
* @param $service
* @return mixed
* @deprecated New services must be registered using Dependency Injection Container
*/
protected function propagate($service)
{
Expand Down
Loading

0 comments on commit 6e6a515

Please sign in to comment.