Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions app/Events/SponsorServices/SummitMediaFileTypeCreatedEventDTO.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php namespace App\Events\SponsorServices;

/*
* Copyright 2026 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

class SummitMediaFileTypeCreatedEventDTO
{
private int $id;
private string $name;
private string $description;
private string $allowed_extensions;

public function __construct(
int $id,
string $name,
string $description,
string $allowed_extensions
)
{
$this->id = $id;
$this->name = $name;
$this->description = $description;
$this->allowed_extensions = $allowed_extensions;
}

public static function fromSummitMediaFileType($summit_media_file_type): self
{
return new self(
$summit_media_file_type->getId(),
$summit_media_file_type->getName(),
$summit_media_file_type->getDescription(),
$summit_media_file_type->getAllowedExtensions(),
);
}

public function serialize(): array
{
return [
'id' => $this->id,
'name' => $this->name,
'description' => $this->description,
'allowed_extensions' => $this->allowed_extensions
];
}
}
21 changes: 21 additions & 0 deletions app/Events/SponsorServices/SummitMediaFileTypeDomainEvents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php namespace App\Events\SponsorServices;

/*
* Copyright 2026 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

class SummitMediaFileTypeDomainEvents
{
const string SummitMediaFileTypeCreated = 'summit_media_file_type_created';
const string SummitMediaFileTypeUpdated = 'summit_media_file_type_updated';
const string SummitMediaFileTypeDeleted = 'summit_media_file_type_deleted';
}
26 changes: 23 additions & 3 deletions app/Services/Model/Imp/SummitMediaFileTypeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
* limitations under the License.
**/

use App\Events\SponsorServices\DeletedEventDTO;
use App\Events\SponsorServices\SummitMediaFileTypeCreatedEventDTO;
use App\Events\SponsorServices\SummitMediaFileTypeDomainEvents;
use App\Jobs\SponsorServices\PublishSponsorServiceDomainEventsJob;
use App\Models\Foundation\Summit\Factories\SummitMediaFileTypeFactory;
use App\Models\Foundation\Summit\Repositories\ISummitMediaFileTypeRepository;
use App\Services\Model\ISummitMediaFileTypeService;
Expand Down Expand Up @@ -49,14 +53,20 @@ public function __construct
*/
public function add(array $payload): SummitMediaFileType
{
return $this->tx_service->transaction(function() use($payload){
$media_file_type = $this->tx_service->transaction(function() use($payload){
$type = $this->repository->getByName(trim($payload['name']));
if(!is_null($type))
throw new ValidationException(sprintf("Name %s already exists.", $payload['name']));
$type = SummitMediaFileTypeFactory::build($payload);
$this->repository->add($type);
return $type;
});

PublishSponsorServiceDomainEventsJob::dispatch(
SummitMediaFileTypeCreatedEventDTO::fromSummitMediaFileType($media_file_type)->serialize(),
SummitMediaFileTypeDomainEvents::SummitMediaFileTypeCreated);

return $media_file_type;
}

/**
Expand All @@ -77,7 +87,13 @@ public function update(int $id, array $payload): SummitMediaFileType
throw new ValidationException(sprintf("Name %s already exists.", $payload['name']));
}

return SummitMediaFileTypeFactory::populate($type, $payload);
$media_file_type = SummitMediaFileTypeFactory::populate($type, $payload);

PublishSponsorServiceDomainEventsJob::dispatch(
SummitMediaFileTypeCreatedEventDTO::fromSummitMediaFileType($media_file_type)->serialize(),
SummitMediaFileTypeDomainEvents::SummitMediaFileTypeUpdated);

return $media_file_type;
});
}

Expand All @@ -94,6 +110,10 @@ public function delete(int $id): void
throw new ValidationException("You can not delete a system defined type.");

$this->repository->delete($type);

PublishSponsorServiceDomainEventsJob::dispatch(
DeletedEventDTO::fromEntity($type)->serialize(),
SummitMediaFileTypeDomainEvents::SummitMediaFileTypeDeleted);
});
}
}
}
3 changes: 3 additions & 0 deletions config/queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@
* - summit_created ( see app/Events/SponsorServices/SummitDomainEvents.php )
* - summit_updated
* - summit_deleted
* - summit_media_file_type_created ( see app/Events/SponsorServices/SummitMediaFileTypeDomainEvents.php )
* - summit_media_file_type_updated
* - summit_media_file_type_deleted
*/
'domain_events_message_broker' => [
'driver' => 'rabbitmq',
Expand Down