2021-01-28 08:08:38 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2021-06-04 15:52:51 -04:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2021-01-28 08:08:38 -05:00
|
|
|
*/
|
|
|
|
|
namespace OC\AppFramework\Bootstrap;
|
|
|
|
|
|
2026-02-11 04:35:55 -05:00
|
|
|
use OC\AppFramework\Utility\SimpleContainer;
|
|
|
|
|
|
2021-01-28 08:08:38 -05:00
|
|
|
/**
|
|
|
|
|
* @psalm-immutable
|
|
|
|
|
*/
|
|
|
|
|
class ServiceFactoryRegistration extends ARegistration {
|
|
|
|
|
/**
|
|
|
|
|
* @var callable
|
2026-02-11 04:35:55 -05:00
|
|
|
* @psalm-var callable(SimpleContainer): mixed
|
2021-01-28 08:08:38 -05:00
|
|
|
*/
|
|
|
|
|
private $factory;
|
|
|
|
|
|
2025-11-18 11:36:29 -05:00
|
|
|
/**
|
|
|
|
|
* @param class-string $name
|
|
|
|
|
*/
|
2025-11-17 09:32:54 -05:00
|
|
|
public function __construct(
|
|
|
|
|
string $appId,
|
|
|
|
|
private string $name,
|
2021-01-28 08:08:38 -05:00
|
|
|
callable $target,
|
2025-11-17 09:32:54 -05:00
|
|
|
private bool $shared,
|
|
|
|
|
) {
|
2021-01-28 08:08:38 -05:00
|
|
|
parent::__construct($appId);
|
|
|
|
|
$this->factory = $target;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getName(): string {
|
|
|
|
|
return $this->name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-02-11 04:35:55 -05:00
|
|
|
* @psalm-return callable(SimpleContainer): mixed
|
2021-01-28 08:08:38 -05:00
|
|
|
*/
|
|
|
|
|
public function getFactory(): callable {
|
|
|
|
|
return $this->factory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function isShared(): bool {
|
|
|
|
|
return $this->shared;
|
|
|
|
|
}
|
|
|
|
|
}
|