◆ __construct()
| UploadPolicyDBRepository::__construct |
( |
protected readonly ilDBInterface |
$db | ) |
|
◆ delete()
Definition at line 93 of file UploadPolicyDBRepository.php.
95 if (null === ($policy_id = $policy->
getPolicyId())) {
99 $query =
"DELETE FROM il_upload_policy WHERE policy_id = %s";
100 $this->db->manipulateF($query, [
'integer'], [$policy_id]);
◆ get()
| UploadPolicyDBRepository::get |
( |
int |
$policy_id | ) |
|
Definition at line 66 of file UploadPolicyDBRepository.php.
References transformToDtoOrAbort().
68 $query =
"SELECT * FROM il_upload_policy WHERE policy_id = %s";
69 $result = $this->db->queryF($query, [
'integer'], [$policy_id]);
70 if (null !== ($dataset = $this->db->fetchObject($result))) {
transformToDtoOrAbort(stdClass $dataset)
◆ getAll()
| UploadPolicyDBRepository::getAll |
( |
| ) |
|
- Returns
- UploadPolicy[]
Definition at line 80 of file UploadPolicyDBRepository.php.
References transformToDtoOrAbort().
82 $query =
"SELECT * FROM il_upload_policy";
83 $result = $this->db->query($query);
85 $upload_policies = [];
86 while (null !== ($dataset = $this->db->fetchObject($result))) {
90 return $upload_policies;
transformToDtoOrAbort(stdClass $dataset)
◆ getDateObject()
| UploadPolicyDBRepository::getDateObject |
( |
string |
$date_string | ) |
|
|
protected |
Returns a datetime object with '00:00:00' as H:i:s to avoid comparison errors because PHP will use the current time automatically otherwise.
Definition at line 142 of file UploadPolicyDBRepository.php.
Referenced by transformToDtoOrAbort().
145 (DateTimeImmutable::createFromFormat(self::MYSQL_DATETIME_FORMAT, $date_string .
' 00:00:00')) ?:
146 throw new LogicException(
"Could not create DateTimeImmutable from '$date_string'.");
◆ getDateString()
| UploadPolicyDBRepository::getDateString |
( |
DateTimeImmutable |
$date | ) |
|
|
protected |
◆ getDateTimeObject()
| UploadPolicyDBRepository::getDateTimeObject |
( |
string |
$date_time_string | ) |
|
|
protected |
◆ getDateTimeString()
| UploadPolicyDBRepository::getDateTimeString |
( |
DateTimeImmutable |
$date_time | ) |
|
|
protected |
◆ missingRequiredField()
| UploadPolicyDBRepository::missingRequiredField |
( |
string |
$field_name | ) |
|
|
protected |
◆ store()
Definition at line 32 of file UploadPolicyDBRepository.php.
References UploadPolicy\getAudience(), UploadPolicy\getAudienceType(), UploadPolicy\getCreateDate(), getDateString(), getDateTimeString(), UploadPolicy\getLastUpdate(), UploadPolicy\getOwnerId(), UploadPolicy\getPolicyId(), UploadPolicy\getScopeDefinition(), UploadPolicy\getTitle(), UploadPolicy\getUploadLimitInMB(), UploadPolicy\getValidFrom(), UploadPolicy\getValidUntil(), and UploadPolicy\isActive().
35 "title" => [
'text', $policy->
getTitle()],
37 "audience" => [
'text', json_encode($policy->
getAudience(), JSON_THROW_ON_ERROR)],
40 "active" => [
'integer', $policy->
isActive()],
44 (null !== ($until = $policy->getValidUntil())) ? $this->
getDateString($until) : null
46 "owner" => [
'integer', $policy->getOwnerId()],
47 "last_update" => [
'timestamp', $this->
getDateTimeString($policy->getLastUpdate())]
50 if (null !== ($policy_id = $policy->
getPolicyId()) && null !== $this->
get($policy_id)) {
55 [
"policy_id" => [
'integer', $policy_id]]
59 $data_for_storage[
"policy_id"] = [
'integer', $this->db->nextId(
"il_upload_policy")];
62 $this->db->insert(
"il_upload_policy", $data_for_storage);
getDateTimeString(DateTimeImmutable $date_time)
getDateString(DateTimeImmutable $date)
◆ transformToDtoOrAbort()
| UploadPolicyDBRepository::transformToDtoOrAbort |
( |
stdClass |
$dataset | ) |
|
|
protected |
- Exceptions
-
| LogicException | if required data is missing |
Definition at line 106 of file UploadPolicyDBRepository.php.
References getDateObject(), getDateTimeObject(), and missingRequiredField().
Referenced by get(), and getAll().
110 $valid_from = (null !== ($from = $dataset?->valid_from)) ? $this->
getDateObject((
string) $from) : null;
111 $valid_until = (null !== ($until = $dataset?->valid_until)) ? $this->
getDateObject((
string) $until) : null;
116 $dataset->upload_limit_in_mb ?? $this->missingRequiredField(
'upload_limit_in_mb'),
117 json_decode((
string) $audience_json,
true, 512, JSON_THROW_ON_ERROR),
getDateObject(string $date_string)
Returns a datetime object with '00:00:00' as H:i:s to avoid comparison errors because PHP will use th...
getDateTimeObject(string $date_time_string)
missingRequiredField(string $field_name)
◆ MYSQL_DATE_FORMAT
| const UploadPolicyDBRepository::MYSQL_DATE_FORMAT = 'Y-m-d' |
|
protected |
◆ MYSQL_DATETIME_FORMAT
| const UploadPolicyDBRepository::MYSQL_DATETIME_FORMAT = 'Y-m-d H:i:s' |
|
protected |
The documentation for this class was generated from the following file: