Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
22.22% |
2 / 9 |
|
16.67% |
1 / 6 |
CRAP | |
0.00% |
0 / 1 |
| DeliveryExecutionCreated | |
22.22% |
2 / 9 |
|
16.67% |
1 / 6 |
22.94 | |
0.00% |
0 / 1 |
| getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getDeliveryExecution | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getWebhookEventName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| serializeForWebhook | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| 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) 2015 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | namespace oat\taoDelivery\models\classes\execution\event; |
| 24 | |
| 25 | use oat\oatbox\user\User; |
| 26 | use oat\tao\model\webhooks\WebhookSerializableEventInterface; |
| 27 | use oat\taoDelivery\model\execution\DeliveryExecutionInterface; |
| 28 | |
| 29 | /** |
| 30 | * Event triggered whenever a new delivery execution is initialised |
| 31 | * |
| 32 | * @author Joel Bout, <joel@taotesting.com> |
| 33 | */ |
| 34 | class DeliveryExecutionCreated implements WebhookSerializableEventInterface, DeliveryExecutionAwareInterface |
| 35 | { |
| 36 | public const EVENT_NAME = self::class; |
| 37 | public const WEBHOOK_EVENT_NAME = 'DeliveryExecutionCreated'; |
| 38 | |
| 39 | /** |
| 40 | * (non-PHPdoc) |
| 41 | * @see \oat\oatbox\event\Event::getName() |
| 42 | */ |
| 43 | public function getName() |
| 44 | { |
| 45 | return self::EVENT_NAME; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * @var DeliveryExecutionInterface delivery execution instance |
| 50 | */ |
| 51 | private $deliveryExecution; |
| 52 | |
| 53 | /** |
| 54 | * @var User user for whom the execution was created |
| 55 | */ |
| 56 | private $user; |
| 57 | |
| 58 | /** |
| 59 | * @param DeliveryExecutionInterface $deliveryExecution |
| 60 | * @param User $user |
| 61 | */ |
| 62 | public function __construct(DeliveryExecutionInterface $deliveryExecution, User $user) |
| 63 | { |
| 64 | $this->deliveryExecution = $deliveryExecution; |
| 65 | $this->user = $user; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Returns newly created delivery execution |
| 70 | * |
| 71 | * @return DeliveryExecutionInterface |
| 72 | */ |
| 73 | public function getDeliveryExecution() |
| 74 | { |
| 75 | return $this->deliveryExecution; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Returns the user for whom the delivery execution was created |
| 80 | * @return User |
| 81 | */ |
| 82 | public function getUser() |
| 83 | { |
| 84 | return $this->user; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * @return string |
| 89 | */ |
| 90 | public function getWebhookEventName() |
| 91 | { |
| 92 | return self::WEBHOOK_EVENT_NAME; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * @return array |
| 97 | * @throws \common_exception_NotFound |
| 98 | */ |
| 99 | public function serializeForWebhook() |
| 100 | { |
| 101 | return [ |
| 102 | 'deliveryExecutionId' => $this->deliveryExecution->getIdentifier() |
| 103 | ]; |
| 104 | } |
| 105 | } |