Skip to content

Commit

Permalink
Merge branch 'release-15.39.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Nov 11, 2024
2 parents 5bbe529 + b7807ab commit f85999a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 20 deletions.
25 changes: 24 additions & 1 deletion common/oatbox/event/EventManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

namespace oat\oatbox\event;

use common_Logger;
use oat\oatbox\service\ConfigurableService;
use oat\oatbox\service\ServiceNotFoundException;
use Throwable;

/**
* The simple placeholder ServiceManager
Expand Down Expand Up @@ -52,9 +54,18 @@ public function trigger($event, $params = [])
$event = is_object($event) ? $event : new GenericEvent($event, $params);

foreach ($this->getListeners($event) as $callback) {
$callbackName = $callback;

if (is_array($callback) && count($callback) == 2) {
list($key, $function) = $callback;
[$key, $function] = $callback;

if (is_object($key)) {
$callbackName = sprintf('%s::%s', get_class($key), $function);
}

if (is_string($key)) {
$callbackName = sprintf('%s::%s', $key, $function);

try {
$service = $container->get($key);
$callback = [$service, $function];
Expand All @@ -64,6 +75,18 @@ public function trigger($event, $params = [])
}
}

if (!is_callable($callback)) {
common_Logger::w(
sprintf(
'Event manager cannot call %s because it is not a callable. '
. 'Notice, that classes registered in DI container cannot be executed during the installation',
$callbackName
)
);

continue;
}

call_user_func($callback, $event);
}
}
Expand Down
30 changes: 17 additions & 13 deletions core/kernel/classes/class.Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,24 +757,28 @@ public function equals(core_kernel_classes_Resource $resource): bool
}

/**
* Whenever or not the current resource is
* an instance of the specified class
* Whenever or not the current resource is an instance of the specified class
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @param Class class
* @return boolean
*/
public function isInstanceOf(core_kernel_classes_Class $class): bool
{
$returnValue = (bool) false;
foreach ($this->getTypes() as $type) {
if ($class->equals($type) || $type->isSubClassOf($class)) {
$returnValue = true;
break;
}
}
return (bool) $returnValue;
return in_array($class->getUri(), $this->getParentClassesIds(), true);
}

public function getRootId(): string
{
$parentClassesIds = $this->getParentClassesIds();

return array_pop($parentClassesIds);
}

/**
* Return the parent class URI of a resource
*/
public function getParentClassId(): ?string
{
return current($this->getParentClassesIds()) ?: null;
}

public function getParentClassesIds(): array
Expand Down
6 changes: 0 additions & 6 deletions migrations/Version202009081435472348_generis.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
use oat\oatbox\user\UserTimezoneServiceInterface;
use oat\tao\scripts\tools\migrations\AbstractMigration;

/**
* run Migration
* index.php '\oat\tao\scripts\tools\Migrations' -c execute -v 'oat\generis\migrations\Version202009081435472348_generis'
* rollback Migration
* php index.php '\oat\tao\scripts\tools\Migrations' -c rollback -v 'oat\generis\migrations\Version202009081435472348_generis'
*/
final class Version202009081435472348_generis extends AbstractMigration
{
public function getDescription(): string
Expand Down

0 comments on commit f85999a

Please sign in to comment.