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. * @package Gedmo\Translatable\Mapping\Event
  11. * @subpackage TranslatableAdapter
  12. * @link http://www.gediminasm.org
  13. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  14. */
  15. interface TranslatableAdapter extends AdapterInterface
  16. {
  17. /**
  18. * Checks if $translationClassName is a subclass
  19. * of personal translation
  20. *
  21. * @param string $translationClassName
  22. * @return boolean
  23. */
  24. function usesPersonalTranslation($translationClassName);
  25. /**
  26. * Get default LogEntry class used to store the logs
  27. *
  28. * @return string
  29. */
  30. function getDefaultTranslationClass();
  31. /**
  32. * Load the translations for a given object
  33. *
  34. * @param object $object
  35. * @param string $translationClass
  36. * @param string $locale
  37. * @return array
  38. */
  39. function loadTranslations($object, $translationClass, $locale);
  40. /**
  41. * Search for existing translation record
  42. *
  43. * AbstractWrapper $wrapped
  44. * @param string $locale
  45. * @param string $field
  46. * @param string $translationClass
  47. * @return mixed - null if nothing is found, Translation otherwise
  48. */
  49. function findTranslation(AbstractWrapper $wrapped, $locale, $field, $translationClass);
  50. /**
  51. * Removes all associated translations for given object
  52. *
  53. * AbstractWrapper $wrapped
  54. * @param string $transClass
  55. * @return void
  56. */
  57. function removeAssociatedTranslations(AbstractWrapper $wrapped, $transClass);
  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. }