Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 24 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| NewSqlNotificationService | |
0.00% |
0 / 24 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| provideSchema | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
2 | |||
| prepareNotification | |
0.00% |
0 / 12 |
|
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) 2020 (original work) Open Assessment Technologies SA; |
| 19 | */ |
| 20 | |
| 21 | namespace oat\tao\model\notification\implementation; |
| 22 | |
| 23 | use common_exception_InconsistentData; |
| 24 | use Doctrine\DBAL\Platforms\AbstractPlatform; |
| 25 | use Exception; |
| 26 | use oat\generis\Helper\UuidPrimaryKeyTrait; |
| 27 | use oat\generis\persistence\sql\SchemaCollection; |
| 28 | use oat\tao\model\notification\Notification; |
| 29 | |
| 30 | /** |
| 31 | * Class NewSqlNotificationService |
| 32 | * |
| 33 | * @deprecated This class is used by client only. It will be moved to client specific extension |
| 34 | */ |
| 35 | class NewSqlNotificationService extends AbstractSqlNotificationService |
| 36 | { |
| 37 | use UuidPrimaryKeyTrait; |
| 38 | |
| 39 | /** |
| 40 | * Allows a class to adapt the schemas as required |
| 41 | * @throws common_exception_InconsistentData |
| 42 | */ |
| 43 | public function provideSchema(SchemaCollection $schemaCollection): void |
| 44 | { |
| 45 | $schema = $schemaCollection->getSchema($this->getOption(self::OPTION_PERSISTENCE)); |
| 46 | $table = $schema->createTable(self::NOTIFICATION_TABLE); |
| 47 | |
| 48 | $table->addColumn(self::NOTIFICATION_FIELD_ID, 'string', ['length' => 36, 'notnull' => true]); |
| 49 | $table->addColumn(self::NOTIFICATION_FIELD_RECIPIENT, 'string', ['length' => 255, 'notnull' => true]); |
| 50 | $table->addColumn(self::NOTIFICATION_FIELD_STATUS, 'integer', ['length' => 255]); |
| 51 | $table->addColumn(self::NOTIFICATION_FIELD_TITLE, 'string', ['length' => 255]); |
| 52 | $table->addColumn(self::NOTIFICATION_FIELD_MESSAGE, 'text', []); |
| 53 | $table->addColumn(self::NOTIFICATION_FIELD_SENDER, 'string', ['length' => 255]); |
| 54 | $table->addColumn(self::NOTIFICATION_FIELD_SENDER_NAME, 'string', ['length' => 255]); |
| 55 | $table->addColumn(self::NOTIFICATION_FIELD_CREATION, 'datetime', ['notnull' => true]); |
| 56 | $table->addColumn(self::NOTIFICATION_FIELD_UPDATED, 'datetime', ['notnull' => true]); |
| 57 | |
| 58 | $table->setPrimaryKey([self::NOTIFICATION_FIELD_ID]); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * @throws Exception |
| 63 | */ |
| 64 | protected function prepareNotification(Notification $notification): array |
| 65 | { |
| 66 | /** @var AbstractPlatform $platform */ |
| 67 | $platform = $this->getPersistence()->getPlatForm(); |
| 68 | return [ |
| 69 | self::NOTIFICATION_FIELD_ID => $this->getUniquePrimaryKey(), |
| 70 | self::NOTIFICATION_FIELD_RECIPIENT => $notification->getRecipient(), |
| 71 | self::NOTIFICATION_FIELD_STATUS => $notification->getStatus(), |
| 72 | self::NOTIFICATION_FIELD_SENDER => $notification->getSenderId(), |
| 73 | self::NOTIFICATION_FIELD_SENDER_NAME => $notification->getSenderName(), |
| 74 | self::NOTIFICATION_FIELD_TITLE => $notification->getTitle(), |
| 75 | self::NOTIFICATION_FIELD_MESSAGE => $notification->getMessage(), |
| 76 | self::NOTIFICATION_FIELD_CREATION => $platform->getNowExpression(), |
| 77 | self::NOTIFICATION_FIELD_UPDATED => $platform->getNowExpression(), |
| 78 | ]; |
| 79 | } |
| 80 | } |