TranslatableAdapter.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. * @return boolean
  20. */
  21. function usesPersonalTranslation($translationClassName);
  22. /**
  23. * Get default LogEntry class used to store the logs
  24. *
  25. * @return string
  26. */
  27. function getDefaultTranslationClass();
  28. /**
  29. * Load the translations for a given object
  30. *
  31. * @param object $object
  32. * @param string $translationClass
  33. * @param string $locale
  34. * @param string $objectClass
  35. * @return array
  36. */
  37. function loadTranslations($object, $translationClass, $locale, $objectClass);
  38. /**
  39. * Search for existing translation record
  40. *
  41. * @param AbstractWrapper $wrapped
  42. * @param string $locale
  43. * @param string $field
  44. * @param string $translationClass
  45. * @param string $objectClass
  46. * @return mixed - null if nothing is found, Translation otherwise
  47. */
  48. function findTranslation(AbstractWrapper $wrapped, $locale, $field, $translationClass, $objectClass);
  49. /**
  50. * Removes all associated translations for given object
  51. *
  52. * @param AbstractWrapper $wrapped
  53. * @param string $transClass
  54. * @param string $objectClass
  55. * @return void
  56. */
  57. function removeAssociatedTranslations(AbstractWrapper $wrapped, $transClass, $objectClass);
  58. /**
  59. * Inserts the translation record
  60. *
  61. * @param object $translation
  62. * @return void
  63. */
  64. function insertTranslationRecord($translation);
  65. /**
  66. * Get the transformed value for translation
  67. * storage
  68. *
  69. * @param object $object
  70. * @param string $field
  71. * @param mixed $value
  72. * @return mixed
  73. */
  74. function getTranslationValue($object, $field, $value = false);
  75. /**
  76. * Transform the value from database
  77. * for translation
  78. *
  79. * @param object $object
  80. * @param string $field
  81. * @param mixed $value
  82. */
  83. function setTranslationValue($object, $field, $value);
  84. }