TEMPLATE_ABSTRACT 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. // vim: expandtab sw=4 ts=4 sts=4:
  3. /**
  4. * This file contains the basic structure for an abstract class defining a
  5. * transformation.
  6. * For instructions, read the documentation
  7. *
  8. * @package PhpMyAdmin-Transformations
  9. * @subpackage [TransformationName]
  10. */
  11. declare(strict_types=1);
  12. namespace PhpMyAdmin\Plugins\Transformations\Abs;
  13. use PhpMyAdmin\Plugins\IOTransformationsPlugin;
  14. use stdClass;
  15. /**
  16. * Provides common methods for all of the [TransformationName] transformations plugins.
  17. *
  18. * @package PhpMyAdmin
  19. */
  20. abstract class [TransformationName]TransformationsPlugin
  21. extends IOTransformationsPlugin
  22. {
  23. /**
  24. * Gets the transformation description of the specific plugin
  25. *
  26. * @return string
  27. */
  28. public static function getInfo()
  29. {
  30. return __(
  31. 'Description of the transformation.'
  32. );
  33. }
  34. /**
  35. * Does the actual work of each specific transformations plugin.
  36. *
  37. * @param string $buffer text to be transformed
  38. * @param array $options transformation options
  39. * @param stdClass|null $meta meta information
  40. *
  41. * @return string
  42. */
  43. public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
  44. {
  45. // possibly use a global transform and feed it with special options
  46. // further operations on $buffer using the $options[] array.
  47. // You can evaluate the propagated $meta Object. It's contained fields are described in https://www.php.net/mysql_fetch_field.
  48. // This stored information can be used to get the field information about the transformed field.
  49. // $meta->mimetype contains the original MimeType of the field (i.e. 'text/plain', 'image/jpeg' etc.)
  50. return $buffer;
  51. }
  52. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  53. /**
  54. * Gets the TransformationName of the specific plugin
  55. *
  56. * @return string
  57. */
  58. public static function getName()
  59. {
  60. return "[TransformationName]";
  61. }
  62. }
  63. ?>