Alert.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace App\Libs\Push\HuaWei\Admin\Msg\Apns;
  3. use App\Libs\Push\HuaWei\Admin\Constants;
  4. use App\Libs\Push\HuaWei\Admin\PushLogConfig;
  5. class Alert
  6. {
  7. private $title;
  8. private $body;
  9. private $title_loc_key;
  10. private $title_loc_args;
  11. private $action_loc_key;
  12. private $loc_key;
  13. private $loc_args;
  14. private $launch_image;
  15. private $fields;
  16. public function title($value)
  17. {
  18. $this->title = $value;
  19. }
  20. public function body($value)
  21. {
  22. $this->body = $value;
  23. }
  24. public function title_loc_key($value)
  25. {
  26. $this->title_loc_key = $value;
  27. }
  28. public function title_loc_args($value)
  29. {
  30. $this->title_loc_args = $value;
  31. }
  32. public function action_loc_key($value)
  33. {
  34. $this->action_loc_key = $value;
  35. }
  36. public function loc_key($value)
  37. {
  38. $this->loc_key = $value;
  39. }
  40. public function loc_args($value)
  41. {
  42. $this->loc_args = $value;
  43. }
  44. public function launch_image($value)
  45. {
  46. $this->launch_image = $value;
  47. }
  48. public function getFields()
  49. {
  50. return $this->fields;
  51. }
  52. public function buildFields()
  53. {
  54. $keys = array(
  55. 'title',
  56. 'body',
  57. 'title-loc-key',
  58. 'title-loc-args',
  59. 'action-loc-key',
  60. 'loc-key',
  61. 'loc-args',
  62. 'launch-image'
  63. );
  64. foreach ($keys as $key) {
  65. $value = str_replace('-', '_', $key);
  66. PushLogConfig::getSingleInstance()->LogMessage('[' . __CLASS__ . '][before key:' . $key . '][after key:' . $value . ']', Constants::HW_PUSH_LOG_DEBUG_LEVEL);
  67. if (isset($this->$value)) {
  68. $this->fields[$key] = $this->$value;
  69. }
  70. }
  71. PushLogConfig::getSingleInstance()->LogMessage('[' . __CLASS__ . '][buildFields result:' . json_encode($this->fields), Constants::HW_PUSH_LOG_DEBUG_LEVEL);
  72. }
  73. }