Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 7 additions & 2 deletions lib/Horde/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,15 @@ public function __construct($session_flags = 0, array $args = [])
/* Save arguments. */
$this->_args = $args;

/* Setup injector. */
/* Setup injector. Only register the default bindings on an injector we
* created ourselves: registering them again on one handed over by a
* bootstrap shadows instances it already resolved (e.g. SessionLifecycle). */
$injectorProvided = isset($GLOBALS['injector']);
$injector = $GLOBALS['injector'] ??= new Horde_Injector(new Horde_Injector_TopLevel());

(new \Horde\Core\DefaultInjectorBindings())->register($injector);
if (!$injectorProvided) {
(new \Horde\Core\DefaultInjectorBindings())->register($injector);
}

$GLOBALS['registry'] = $this;
$injector->setInstance(__CLASS__, $this);
Expand Down
1 change: 1 addition & 0 deletions src/DefaultInjectorBindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ public function register(Injector $injector): void
'Horde_Perms' => 'Horde_Core_Factory_Perms',
'Horde_Perms_Base' => 'Horde_Core_Factory_Perms',
'Horde_Queue_Storage' => 'Horde_Core_Factory_QueueStorage',
'Horde_Registry' => [Factory\HordeRegistryFactory::class, 'create'],
'Horde_Routes_Mapper' => 'Horde_Core_Factory_Mapper',
HordeRoutesMapper::class => 'Horde_Core_Factory_Mapper',
'Horde_Routes_Matcher' => 'Horde_Core_Factory_Matcher',
Expand Down
30 changes: 30 additions & 0 deletions src/Factory/HordeRegistryFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/**
* Copyright 2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @copyright 2026 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Core
*/

namespace Horde\Core\Factory;

use Horde\Injector\Injector;
use Horde_Registry;

class HordeRegistryFactory
{
public function create(Injector $injector): Horde_Registry
{
$GLOBALS['injector'] ??= $injector;

return new Horde_Registry();
}
}
Loading