1
0

GenericMigrationAttribute.php 986 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Migration\Attributes;
  8. use JsonSerializable;
  9. /**
  10. * generic entry, used to replace migration attribute not yet known in current version
  11. * but used in a future release
  12. *
  13. * @since 30.0.0
  14. */
  15. class GenericMigrationAttribute extends MigrationAttribute implements JsonSerializable {
  16. /**
  17. * @param array $details
  18. * @since 30.0.0
  19. */
  20. public function __construct(
  21. private readonly array $details = [],
  22. ) {
  23. parent::__construct(
  24. $details['table'] ?? '',
  25. $details['description'] ?? '',
  26. $details['notes'] ?? []
  27. );
  28. }
  29. /**
  30. * @return string
  31. * @since 30.0.0
  32. */
  33. public function definition(): string {
  34. return json_encode($this->jsonSerialize(), JSON_UNESCAPED_SLASHES);
  35. }
  36. /**
  37. * @return array
  38. * @since 30.0.0
  39. */
  40. public function jsonSerialize(): array {
  41. return $this->details;
  42. }
  43. }