Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
93.33% covered (success)
93.33%
14 / 15
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
TranslationActionEvent
93.33% covered (success)
93.33%
14 / 15
66.67% covered (warning)
66.67%
2 / 3
3.00
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 getName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 jsonSerialize
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; under version 2
7 * of the License (non-upgradable).
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 *
18 * Copyright (c) 2025 (original work) Open Assessment Technologies SA.
19 */
20
21declare(strict_types=1);
22
23namespace oat\tao\model\Translation\Event;
24
25use JsonSerializable;
26use oat\oatbox\event\Event;
27
28class TranslationActionEvent implements Event, JsonSerializable
29{
30    public const ACTION_CREATED = 'translation.created';
31    public const ACTION_UPDATED = 'translation.updated';
32    public const ACTION_DELETED = 'translation.deleted';
33
34    private string $action;
35    private string $type;
36    private string $originalResourceId;
37    private string $translationResourceId;
38    private string $locale;
39    private array $data;
40
41    public function __construct(
42        string $action,
43        string $type,
44        string $originalResourceId,
45        string $translationResourceId,
46        string $locale,
47        array $data = []
48    ) {
49        $this->action = $action;
50        $this->type = $type;
51        $this->originalResourceId = $originalResourceId;
52        $this->translationResourceId = $translationResourceId;
53        $this->locale = $locale;
54        $this->data = $data;
55    }
56
57    public function getName(): string
58    {
59        return __CLASS__;
60    }
61
62    public function jsonSerialize(): array
63    {
64        return [
65            'action' => $this->action,
66            'type' => $this->type,
67            'originalResourceId' => $this->originalResourceId,
68            'translationResourceId' => $this->translationResourceId,
69            'locale' => $this->locale,
70            'data' => $this->data,
71        ];
72    }
73}