TEMPLATE_ABSTRACT 2.0 KB

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