TranslatableAdapter.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace Gedmo\Translatable\Mapping\Event;
  3. use Gedmo\Mapping\Event\AdapterInterface;
  4. use Gedmo\Tool\Wrapper\AbstractWrapper;
  5. /**
  6. * Doctrine event adapter interface
  7. * for Translatable behavior
  8. *
  9. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  10. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  11. */
  12. interface TranslatableAdapter extends AdapterInterface
  13. {
  14. /**
  15. * Checks if $translationClassName is a subclass
  16. * of personal translation
  17. *
  18. * @param string $translationClassName
  19. *
  20. * @return boolean
  21. */
  22. public function usesPersonalTranslation($translationClassName);
  23. /**
  24. * Get default LogEntry class used to store the logs
  25. *
  26. * @return string
  27. */
  28. public function getDefaultTranslationClass();
  29. /**
  30. * Load the translations for a given object
  31. *
  32. * @param object $object
  33. * @param string $translationClass
  34. * @param string $locale
  35. * @param string $objectClass
  36. *
  37. * @return array
  38. */
  39. public function loadTranslations($object, $translationClass, $locale, $objectClass);
  40. /**
  41. * Search for existing translation record
  42. *
  43. * @param AbstractWrapper $wrapped
  44. * @param string $locale
  45. * @param string $field
  46. * @param string $translationClass
  47. * @param string $objectClass
  48. *
  49. * @return mixed - null if nothing is found, Translation otherwise
  50. */
  51. public function findTranslation(AbstractWrapper $wrapped, $locale, $field, $translationClass, $objectClass);
  52. /**
  53. * Removes all associated translations for given object
  54. *
  55. * @param AbstractWrapper $wrapped
  56. * @param string $transClass
  57. * @param string $objectClass
  58. */
  59. public function removeAssociatedTranslations(AbstractWrapper $wrapped, $transClass, $objectClass);
  60. /**
  61. * Inserts the translation record
  62. *
  63. * @param object $translation
  64. */
  65. public function insertTranslationRecord($translation);
  66. /**
  67. * Get the transformed value for translation
  68. * storage
  69. *
  70. * @param object $object
  71. * @param string $field
  72. * @param mixed $value
  73. *
  74. * @return mixed
  75. */
  76. public function getTranslationValue($object, $field, $value = false);
  77. /**
  78. * Transform the value from database
  79. * for translation
  80. *
  81. * @param object $object
  82. * @param string $field
  83. * @param mixed $value
  84. */
  85. public function setTranslationValue($object, $field, $value);
  86. }