InstanceAppConfig.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Libs\Push\HuaWei\Admin\Msg\InstanceApp;
  3. use App\Libs\Push\HuaWei\Admin\Constants;
  4. use App\Libs\Push\HuaWei\Admin\PushLogConfig;
  5. class InstanceAppConfig
  6. {
  7. //push_type 0:notification;1,pass-through
  8. private $pushtype;
  9. private $pushbody;
  10. private $fields;
  11. public function __construct()
  12. {
  13. }
  14. public function pushtype($value)
  15. {
  16. $this->pushtype = $value;
  17. }
  18. public function pushbody($value)
  19. {
  20. $this->pushbody = $value;
  21. }
  22. public function getFields()
  23. {
  24. $result = "{";
  25. foreach ($this->fields as $key=>$value) {
  26. $result = $result .$key.":".json_encode($value).",";
  27. PushLogConfig::getSingleInstance()->LogMessage('[' . __CLASS__ . '][result:' .$result, Constants::HW_PUSH_LOG_DEBUG_LEVEL);
  28. }
  29. if (strlen($result) > 1){
  30. $result = rtrim($result, ",");
  31. }
  32. $result = $result."}";
  33. return $result;
  34. }
  35. public function buildFields()
  36. {
  37. $keys = array(
  38. 'pushtype',
  39. 'pushbody'
  40. );
  41. foreach ($keys as $key) {
  42. PushLogConfig::getSingleInstance()->LogMessage('[' . __CLASS__ . '][key:' . $key . '][value:' . json_encode($this->$key) . ']', Constants::HW_PUSH_LOG_DEBUG_LEVEL);
  43. if (isset($this->$key)) {
  44. $this->fields[$key] = $this->$key;
  45. }
  46. }
  47. PushLogConfig::getSingleInstance()->LogMessage('[' . __CLASS__ . '][buildFields result:' . json_encode($this->fields), Constants::HW_PUSH_LOG_DEBUG_LEVEL);
  48. }
  49. }