54 lines
1.0 KiB
PHP
54 lines
1.0 KiB
PHP
<?php
|
|
/**
|
|
* @package ogre-consent
|
|
* @author cleverogre
|
|
* @copyright 2026 CleverOgre
|
|
* @license GLP-3.0-or-later
|
|
* @version 0.0.0
|
|
* @since 0.0.0
|
|
*/
|
|
|
|
namespace Ogre\Consent;
|
|
|
|
use Ogre\Singleton;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
final class Services {
|
|
use Singleton;
|
|
|
|
protected array $services = [];
|
|
|
|
public function register(Service $service): void
|
|
{
|
|
$this->services[] = $service;
|
|
}
|
|
|
|
public function get_services(): array
|
|
{
|
|
return $this->services;
|
|
}
|
|
|
|
public function get_services_by_purpose(string $purpose): array
|
|
{
|
|
return array_filter(
|
|
$this->services,
|
|
fn (Service $service): bool => $service->get_purpose() == $purpose
|
|
);
|
|
}
|
|
|
|
public function get_config(): array
|
|
{
|
|
return array_map(
|
|
fn (Service $service): array => $service->get_config(),
|
|
array_values(array_filter(
|
|
$this->services,
|
|
fn (Service $service): bool => $service->is_enabled()
|
|
))
|
|
);
|
|
}
|
|
|
|
}
|
|
|
|
Services::instance();
|