tmgmt.entity.remote.inc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. /*
  3. * @file
  4. * Contains remote entity class.
  5. */
  6. /**
  7. * Entity class for the tmgmt_remote entity.
  8. *
  9. * @ingroup tmgmt_job
  10. */
  11. class TMGMTRemote extends Entity {
  12. /**
  13. * Primary key.
  14. *
  15. * @var int
  16. */
  17. public $trid;
  18. /**
  19. * TMGMTJob identifier.
  20. *
  21. * @var int
  22. */
  23. public $tjid;
  24. /**
  25. * TMGMTJobItem identifier.
  26. *
  27. * @var int
  28. */
  29. public $tjiid;
  30. /**
  31. * Translation job data item key.
  32. *
  33. * @var string
  34. */
  35. public $data_item_key;
  36. /**
  37. * Custom remote identifier 1.
  38. *
  39. * @var string
  40. */
  41. public $remote_identifier_1;
  42. /**
  43. * Custom remote identifier 2.
  44. *
  45. * @var string
  46. */
  47. public $remote_identifier_2;
  48. /**
  49. * Custom remote identifier 3.
  50. *
  51. * @var string
  52. */
  53. public $remote_identifier_3;
  54. /**
  55. * Remote job url.
  56. *
  57. * @var string
  58. */
  59. public $remote_url;
  60. /**
  61. * Word count provided by the remote service.
  62. *
  63. * @var int
  64. */
  65. public $word_count;
  66. /**
  67. * Amount charged for the remote translation job.
  68. *
  69. * @var int
  70. */
  71. public $amount;
  72. /**
  73. * Amount charged currency.
  74. *
  75. * @var string
  76. */
  77. public $currency;
  78. /**
  79. * Custom remote data.
  80. *
  81. * @var array
  82. */
  83. public $remote_data;
  84. /**
  85. * Gets translation job.
  86. *
  87. * @return TMGMTJob
  88. */
  89. function getJob() {
  90. return tmgmt_job_load($this->tjid);
  91. }
  92. /**
  93. * Gets translation job item.
  94. *
  95. * @return TMGMTJobItem
  96. */
  97. function getJobItem() {
  98. if (!empty($this->tjiid)) {
  99. return tmgmt_job_item_load($this->tjiid);
  100. }
  101. return NULL;
  102. }
  103. /**
  104. * Adds data to the remote_data storage.
  105. *
  106. * @param string $key
  107. * Key through which the data will be accessible.
  108. * @param $value
  109. * Value to store.
  110. */
  111. function addRemoteData($key, $value) {
  112. $this->remote_data[$key] = $value;
  113. }
  114. /**
  115. * Gets data from remote_data storage.
  116. *
  117. * @param string $key
  118. * Access key for the data.
  119. *
  120. * @return mixed
  121. * Stored data.
  122. */
  123. function getRemoteData($key) {
  124. return $this->remote_data[$key];
  125. }
  126. /**
  127. * Removes data from remote_data storage.
  128. *
  129. * @param string $key
  130. * Access key for the data that are to be removed.
  131. */
  132. function removeRemoteData($key) {
  133. unset($this->remote_data[$key]);
  134. }
  135. }