2024-08-20 15:06:57 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2024-08-22 14:19:42 +02:00
|
|
|
namespace OCA\OrganizationFolders\OrganizationProvider;
|
2024-08-20 15:06:57 +02:00
|
|
|
|
|
|
|
use OCP\EventDispatcher\IEventDispatcher;
|
|
|
|
use OCP\Server;
|
|
|
|
|
2024-08-22 14:19:42 +02:00
|
|
|
use OCA\OrganizationFolders\Events\RegisterOrganizationProviderEvent;
|
2024-08-20 15:06:57 +02:00
|
|
|
|
2024-08-22 14:19:42 +02:00
|
|
|
class OrganizationProviderManager {
|
|
|
|
private array $organizationProviders = [];
|
2024-08-20 15:06:57 +02:00
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
IEventDispatcher $dispatcher,
|
|
|
|
) {
|
2024-08-22 14:19:42 +02:00
|
|
|
$event = new RegisterOrganizationProviderEvent($this);
|
2024-08-20 15:06:57 +02:00
|
|
|
$dispatcher->dispatchTyped($event);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-08-22 14:19:42 +02:00
|
|
|
* @return OrganizationProvider[]
|
2024-08-20 15:06:57 +02:00
|
|
|
*/
|
2024-08-22 14:19:42 +02:00
|
|
|
public function getOrganizationProviders(): array {
|
|
|
|
return $this->organizationProviders;
|
2024-08-20 15:06:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-08-22 14:19:42 +02:00
|
|
|
* @return OrganizationProvider
|
2024-08-20 15:06:57 +02:00
|
|
|
*/
|
2024-08-22 14:19:42 +02:00
|
|
|
public function getOrganizationProvider($id): ?OrganizationProvider {
|
|
|
|
return $this->organizationProviders[$id];
|
2024-08-20 15:06:57 +02:00
|
|
|
}
|
|
|
|
|
2024-08-22 14:19:42 +02:00
|
|
|
public function registerOrganizationProvider(OrganizationProvider $organizationProvider): self {
|
|
|
|
$this->organizationProviders[$organizationProvider->getId()] = $organizationProvider;
|
2024-08-20 15:06:57 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|