DummyContentHandlerForTesting.php 958 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. class DummyContentHandlerForTesting extends ContentHandler {
  3. public function __construct( $dataModel, $formats = [ DummyContentForTesting::MODEL_ID ] ) {
  4. parent::__construct( $dataModel, $formats );
  5. }
  6. /**
  7. * @see ContentHandler::serializeContent
  8. *
  9. * @param Content $content
  10. * @param string|null $format
  11. *
  12. * @return string
  13. */
  14. public function serializeContent( Content $content, $format = null ) {
  15. return $content->serialize();
  16. }
  17. /**
  18. * @see ContentHandler::unserializeContent
  19. *
  20. * @param string $blob
  21. * @param string|null $format Unused.
  22. *
  23. * @return Content
  24. */
  25. public function unserializeContent( $blob, $format = null ) {
  26. $d = unserialize( $blob );
  27. return new DummyContentForTesting( $d );
  28. }
  29. /**
  30. * Creates an empty Content object of the type supported by this ContentHandler.
  31. * @return DummyContentForTesting
  32. */
  33. public function makeEmptyContent() {
  34. return new DummyContentForTesting( '' );
  35. }
  36. }