ILIAS
trunk Revision v11.0_alpha-2638-g80c1d007f79
◀ ilDoc Overview
UserSettings.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
namespace
ILIAS\TermsOfService
;
22
23
use
ILIAS\LegalDocuments\ConsumerToolbox\UserSettings
as
UserSettingsInterface
;
24
use
ILIAS\LegalDocuments\ConsumerToolbox\Marshal
;
25
use
ilObjUser
;
26
use
ILIAS\LegalDocuments\ConsumerToolbox\SelectSetting
;
27
use
ILIAS\LegalDocuments\ConsumerToolbox\Convert
;
28
use
ILIAS\LegalDocuments\ConsumerToolbox\Setting
;
29
use
ILIAS\Refinery\Factory
as
Refinery
;
30
use
DateTimeImmutable
;
31
32
class
UserSettings
implements
UserSettingsInterface
33
{
34
public
function
__construct
(
35
private
readonly
ilObjUser
$user,
36
private
readonly
SelectSetting
$user_pref,
37
private
readonly
Refinery
$refinery
38
) {
39
}
40
44
public
function
withdrawalRequested
():
Setting
45
{
46
return
$this->user_pref->typed(
'consent_withdrawal_requested'
, fn(
Marshal
$m) => $m->
boolean
());
47
}
48
52
public
function
agreeDate
():
Setting
53
{
54
return
$this->
setting
($this->
convert
());
55
}
56
57
private
function
setting
(
Convert
$convert):
Setting
58
{
59
return
new
Setting
(
60
fn() => $convert->
fromString
()->transform($this->
user
->getAgreeDate()),
61
function
($value) use ($convert):
void
{
62
$this->
user
->setAgreeDate($convert->
toString
()->transform($value));
63
$this->
user
->update();
64
}
65
);
66
}
67
68
private
function
convert
():
Convert
69
{
70
$custom = $this->
refinery
->custom()->transformation(...);
71
$null_or = fn($next) => $this->
refinery
->byTrying([$this->
refinery
->null(), $next]);
72
73
return
new
Convert
(
74
$null_or($this->
refinery
->to()->dateTime()),
75
$null_or($custom(fn(
DateTimeImmutable
$d
):
string
=> $d->format(
'Y-m-d H:i:s'
)))
76
);
77
}
78
}
ILIAS\TermsOfService
Definition:
Consumer.php:21
ILIAS\UI\examples\Layout\Page\Standard\$refinery
$refinery
Definition:
ui.php:137
DateTimeImmutable
ILIAS\TermsOfService\UserSettings\convert
convert()
Definition:
UserSettings.php:68
Convert
ILIAS\TermsOfService\UserSettings\setting
setting(Convert $convert)
Definition:
UserSettings.php:57
ILIAS\TermsOfService\UserSettings
Definition:
UserSettings.php:32
ILIAS\LegalDocuments\ConsumerToolbox\Convert\toString
toString()
Definition:
Convert.php:38
ILIAS\TermsOfService\UserSettings\agreeDate
agreeDate()
Definition:
UserSettings.php:52
ILIAS\Repository\user
user()
Definition:
trait.GlobalDICDomainServices.php:66
Marshal
ILIAS\LegalDocuments\ConsumerToolbox\Marshal\boolean
boolean()
Definition:
Marshal.php:47
Vendor\Package\$d
$d
Definition:
example_cleaned.php:49
Setting
ILIAS\Repository\refinery
refinery()
Definition:
trait.GlobalDICDomainServices.php:76
ILIAS\LegalDocuments\ConsumerToolbox\Marshal
Definition:
Marshal.php:29
ILIAS\TermsOfService\UserSettings\__construct
__construct(private readonly ilObjUser $user, private readonly SelectSetting $user_pref, private readonly Refinery $refinery)
Definition:
UserSettings.php:34
ilObjUser
Factory
UserSettings
SelectSetting
ILIAS\LegalDocuments\ConsumerToolbox\Convert\fromString
fromString()
Definition:
Convert.php:33
ILIAS\TermsOfService\UserSettings\withdrawalRequested
withdrawalRequested()
Definition:
UserSettings.php:44
ILIAS\LegalDocuments\ConsumerToolbox\Setting
A
Definition:
Setting.php:28
ILIAS\LegalDocuments\ConsumerToolbox\SelectSetting
Definition:
SelectSetting.php:25
ILIAS\LegalDocuments\ConsumerToolbox\Convert
Definition:
Convert.php:25
components
ILIAS
TermsOfService
classes
UserSettings.php
Generated on Sun Aug 31 2025 23:02:48 for ILIAS by
1.8.13 (using
Doxyfile
)