This commit is contained in:
+20
-7
@@ -10,9 +10,7 @@
|
||||
|
||||
namespace Ogre\Consent;
|
||||
|
||||
use Ogre\Consent as Plugin;
|
||||
use Ogre\Singleton;
|
||||
use WP_HTML_Tag_Processor;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -20,19 +18,34 @@ final class Services {
|
||||
use Singleton;
|
||||
|
||||
protected array $services = [];
|
||||
|
||||
protected function __construct() {
|
||||
|
||||
}
|
||||
|
||||
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(), $this->services);
|
||||
return array_map(
|
||||
fn (Service $service): array => $service->get_config(),
|
||||
array_values(array_filter(
|
||||
$this->services,
|
||||
fn (Service $service): bool => $service->is_enabled()
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user