TranslatableAdapter.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. * @param string $objectClass
  38. * @return array
  39. */
  40. function loadTranslations($object, $translationClass, $locale, $objectClass);
  41. /**
  42. * Search for existing translation record
  43. *
  44. * AbstractWrapper $wrapped
  45. * @param string $locale
  46. * @param string $field
  47. * @param string $translationClass
  48. * @param string $objectClass
  49. * @return mixed - null if nothing is found, Translation otherwise
  50. */
  51. function findTranslation(AbstractWrapper $wrapped, $locale, $field, $translationClass, $objectClass);
  52. /**
  53. * Removes all associated translations for given object
  54. *
  55. * AbstractWrapper $wrapped
  56. * @param string $transClass
  57. * @param string $objectClass
  58. * @return void
  59. */
  60. function removeAssociatedTranslations(AbstractWrapper $wrapped, $transClass, $objectClass);
  61. /**
  62. * Inserts the translation record
  63. *
  64. * @param object $translation
  65. * @return void
  66. */
  67. function insertTranslationRecord($translation);
  68. /**
  69. * Get the transformed value for translation
  70. * storage
  71. *
  72. * @param object $object
  73. * @param string $field
  74. * @param mixed $value
  75. * @return mixed
  76. */
  77. function getTranslationValue($object, $field, $value = false);
  78. /**
  79. * Transform the value from database
  80. * for translation
  81. *
  82. * @param object $object
  83. * @param string $field
  84. * @param mixed $value
  85. */
  86. function setTranslationValue($object, $field, $value);
  87. }