0
0
Fork 0
mirror of https://github.com/verdigado/organization_folders.git synced 2024-11-22 04:38:09 +01:00

implemented organization provider registration

This commit is contained in:
Jonathan Treffler 2024-08-20 15:06:57 +02:00 committed by Jonathan Treffler
parent c0e2ec9d2e
commit 02bb8a330f
3 changed files with 82 additions and 0 deletions

View file

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace OCA\OrganizationFolders\Events;
use OCP\EventDispatcher\Event;
use OCA\OrganizationFolders\Transport\OrganisationProviderManager;
/**
* This event is triggered during the initialization of Organisation Folders.
*/
class RegisterOrganisationProviderEvent extends Event {
/** @var OrganisationProviderManager */
private $organisationProviderManager;
public function __construct(OrganisationProviderManager $organisationProviderManager) {
parent::__construct();
$this->organisationProviderManager = $organisationProviderManager;
}
public function getOrganisationProviderManager(): OrganisationProviderManager {
return $this->organisationProviderManager;
}
}

View file

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace OCA\OrganizationFolders\OrganisationProvider;
abstract class OrganisationProvider {
protected $id;
public function getId() {
return $this->id;
}
// TODO: functions to access organisation structure
}

View file

@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace OCA\OrganizationFolders\OrganisationProvider;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Server;
use OCA\OrganizationFolders\Events\RegisterOrganisationProviderEvent;
class OrganisationProviderManager {
private array $organisationProviders = [];
public function __construct(
IEventDispatcher $dispatcher,
) {
$event = new RegisterOrganisationProviderEvent($this);
$dispatcher->dispatchTyped($event);
}
/**
* @return OrganisationProvider[]
*/
public function getOrganisationProviders(): array {
return $this->organisationProviders;
}
/**
* @return OrganisationProvider
*/
public function getOrganisationProvider($id): ?OrganisationProvider {
return $this->organisationProviders[$id];
}
public function registerOrganisationProvider(OrganisationProvider $organisationProvider): self {
$this->organisationProviders[$organisationProvider->getId()] = $organisationProvider;
return $this;
}
}