AddMissingColumnsEvent.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\DB\Events;
  8. /**
  9. * Event to allow apps to register information about missing database columns
  10. *
  11. * This event will be dispatched for checking on the admin settings and when running
  12. * occ db:add-missing-columns which will then create those columns
  13. *
  14. * @since 28.0.0
  15. */
  16. class AddMissingColumnsEvent extends \OCP\EventDispatcher\Event {
  17. /** @var array<array-key, array{tableName: string, columnName: string, typeName: string, options: array{}}> */
  18. private array $missingColumns = [];
  19. /**
  20. * @param mixed[] $options
  21. * @since 28.0.0
  22. */
  23. public function addMissingColumn(string $tableName, string $columnName, string $typeName, array $options): void {
  24. $this->missingColumns[] = [
  25. 'tableName' => $tableName,
  26. 'columnName' => $columnName,
  27. 'typeName' => $typeName,
  28. 'options' => $options,
  29. ];
  30. }
  31. /**
  32. * @since 28.0.0
  33. * @return array<array-key, array{tableName: string, columnName: string, typeName: string, options: array{}}>
  34. */
  35. public function getMissingColumns(): array {
  36. return $this->missingColumns;
  37. }
  38. }