diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 247a140223d..dcb05293b0d 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -649,6 +649,7 @@ return array( 'OCP\\IUserManager' => $baseDir . '/lib/public/IUserManager.php', 'OCP\\IUserSession' => $baseDir . '/lib/public/IUserSession.php', 'OCP\\Image' => $baseDir . '/lib/public/Image.php', + 'OCP\\Install\\Events\\InstallationCompletedEvent' => $baseDir . '/lib/public/Install/Events/InstallationCompletedEvent.php', 'OCP\\L10N\\IFactory' => $baseDir . '/lib/public/L10N/IFactory.php', 'OCP\\L10N\\ILanguageIterator' => $baseDir . '/lib/public/L10N/ILanguageIterator.php', 'OCP\\LDAP\\IDeletionFlagSupport' => $baseDir . '/lib/public/LDAP/IDeletionFlagSupport.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 9f3d6c2c3dd..34e3bcced48 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -690,6 +690,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\IUserManager' => __DIR__ . '/../../..' . '/lib/public/IUserManager.php', 'OCP\\IUserSession' => __DIR__ . '/../../..' . '/lib/public/IUserSession.php', 'OCP\\Image' => __DIR__ . '/../../..' . '/lib/public/Image.php', + 'OCP\\Install\\Events\\InstallationCompletedEvent' => __DIR__ . '/../../..' . '/lib/public/Install/Events/InstallationCompletedEvent.php', 'OCP\\L10N\\IFactory' => __DIR__ . '/../../..' . '/lib/public/L10N/IFactory.php', 'OCP\\L10N\\ILanguageIterator' => __DIR__ . '/../../..' . '/lib/public/L10N/ILanguageIterator.php', 'OCP\\LDAP\\IDeletionFlagSupport' => __DIR__ . '/../../..' . '/lib/public/LDAP/IDeletionFlagSupport.php', diff --git a/lib/private/Setup.php b/lib/private/Setup.php index 5f91dc10692..24fe3df4096 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -23,12 +23,14 @@ use OC\User\BackgroundJobs\CleanupDeletedUsers; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJobList; use OCP\Defaults; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Http\Client\IClientService; use OCP\IAppConfig; use OCP\IConfig; use OCP\IGroup; use OCP\IGroupManager; use OCP\IL10N; +use OCP\Install\Events\InstallationCompletedEvent; use OCP\IRequest; use OCP\IURLGenerator; use OCP\IUserManager; @@ -51,6 +53,7 @@ class Setup { protected LoggerInterface $logger, protected ISecureRandom $random, protected Installer $installer, + protected IEventDispatcher $eventDispatcher, ) { $this->l10n = $l10nFactory->get('lib'); } @@ -495,6 +498,13 @@ class Setup { } } + // Dispatch installation completed event + $adminUsername = !$disableAdminUser ? ($options['adminlogin'] ?? null) : null; + $adminEmail = !empty($options['adminemail']) ? $options['adminemail'] : null; + $this->eventDispatcher->dispatchTyped( + new InstallationCompletedEvent($dataDir, $adminUsername, $adminEmail) + ); + return $error; } diff --git a/tests/lib/SetupTest.php b/tests/lib/SetupTest.php index 0be7eab36f6..1a48803ecd6 100644 --- a/tests/lib/SetupTest.php +++ b/tests/lib/SetupTest.php @@ -13,6 +13,7 @@ use OC\Installer; use OC\Setup; use OC\SystemConfig; use OCP\Defaults; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IL10N; use OCP\L10N\IFactory as IL10NFactory; use OCP\Security\ISecureRandom; @@ -28,6 +29,7 @@ class SetupTest extends \Test\TestCase { protected LoggerInterface $logger; protected ISecureRandom $random; protected Installer $installer; + protected IEventDispatcher $eventDispatcher; protected function setUp(): void { parent::setUp(); @@ -42,9 +44,10 @@ class SetupTest extends \Test\TestCase { $this->logger = $this->createMock(LoggerInterface::class); $this->random = $this->createMock(ISecureRandom::class); $this->installer = $this->createMock(Installer::class); + $this->eventDispatcher = $this->createMock(IEventDispatcher::class); $this->setupClass = $this->getMockBuilder(Setup::class) ->onlyMethods(['class_exists', 'is_callable', 'getAvailableDbDriversForPdo']) - ->setConstructorArgs([$this->config, $this->iniWrapper, $this->l10nFactory, $this->defaults, $this->logger, $this->random, $this->installer]) + ->setConstructorArgs([$this->config, $this->iniWrapper, $this->l10nFactory, $this->defaults, $this->logger, $this->random, $this->installer, $this->eventDispatcher]) ->getMock(); }