IContextPortation.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\WorkflowEngine\EntityContext;
  8. /**
  9. * Interface IContextPortation
  10. *
  11. * Occasionally an IEntity needs to be reused not in the same, but a new
  12. * request. As IEntities receive custom context information during a flow
  13. * cycle, sometimes it might be necessary to export context identifiers to
  14. * be able to recreate the state at a later point. For example: handling
  15. * translations in a notification INotifier.
  16. *
  17. *
  18. * @since 20.0.0
  19. */
  20. interface IContextPortation {
  21. /**
  22. * All relevant context identifiers that are needed to restore the state
  23. * of an entity shall be returned with this method. The resulting array
  24. * must be JSON-serializable.
  25. *
  26. * @since 20.0.0
  27. */
  28. public function exportContextIDs(): array;
  29. /**
  30. * This method receives the array as returned by `exportContextIDs()` in
  31. * order to restore the state of the IEntity if necessary.
  32. *
  33. * @since 20.0.0
  34. */
  35. public function importContextIDs(array $contextIDs): void;
  36. }