ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
PushNotificationObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29
31{
35 public function __construct(protected readonly array $provider, protected readonly Config $config)
36 {
37 }
38
39 public function build(): Artifact
40 {
41 return new ArrayArtifact(array_map(fn($p) => $p::class, $this->provider));
42 }
43
44 public function getPreconditions(Environment $environment): array
45 {
46 return [
48 ];
49 }
50
51 public function getArtifactName(): string
52 {
53 return 'push_providers';
54 }
55
56 public function achieve(Environment $environment): Environment
57 {
58 if (!($this->config instanceof NullConfig)) {
59 $settings = $environment->getResource(Environment::RESOURCE_SETTINGS_FACTORY)->settingsFor('notifications');
60
61 $private_key_path = $this->config->getPrivateKeyPath();
62 if (file_exists($private_key_path)) {
63 $settings->set('private_key_path', $private_key_path);
64
65 $details = openssl_pkey_get_details(openssl_pkey_get_private('file://' . $private_key_path))['ec'];
66 $settings->set(
67 'application_server_key',
68 str_replace(
69 ['+', '/', '='],
70 ['-', '_', ''],
71 base64_encode(hex2bin('04') . $details['x'] . $details['y'])
72 )
73 );
74 } else {
75 throw new InvalidArgumentException('Notification key path is invalid!');
76 }
77 }
78
79 return parent::achieve($environment);
80 }
81}
$settings
Definition: index.php:44
Class Exception Thrown if some procedure did not get the arguments it expected.
An array as an artifact.
This is an objective to build some artifact.
A configuration with no content.
Definition: NullConfig.php:27
achieve(Environment $environment)
Objectives can be achieved.
build()
Build the artifact based.
__construct(protected readonly array $provider, protected readonly Config $config)
getPreconditions(Environment $environment)
Objectives might depend on other objectives.
getArtifactName()
Get the filename where the builder wants to put its artifact.
An artifact is some file that is build on demand per installation and is not shipped with the ILIAS s...
Definition: Artifact.php:28
A configuration for the setup.
Definition: Config.php:27
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.