LZRefillFactory.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace refill;
  3. require_once(BASE_HELPER_PATH . '/refill/RefillBase.php');
  4. require_once(BASE_HELPER_PATH . '/refill/ProviderManager.php');
  5. require_once(BASE_HELPER_PATH . '/refill/policy/IPolicy.php');
  6. require_once(BASE_HELPER_PATH . '/refill/policy/lingzh/policy.php');
  7. require_once(BASE_HELPER_PATH . '/refill/policy/lingzh/chctl.php');
  8. require_once(BASE_HELPER_PATH . '/refill/policy/lingzh/ctl_item.php');
  9. use Log;
  10. use StatesHelper;
  11. class LZRefillFactory extends RefillBase
  12. {
  13. private static $stInstance = null;
  14. public static function instance()
  15. {
  16. if (self::$stInstance == null) {
  17. self::$stInstance = new LZRefillFactory();
  18. }
  19. if(defined('SUPPORT_PTHREAD') && SUPPORT_PTHREAD === true)
  20. {
  21. Log::record("SUPPORT_PTHREAD defined call load",Log::DEBUG);
  22. if(StatesHelper::fetch_state('channel')) {
  23. Log::record("RefillFactory reload channel config.",Log::DEBUG);
  24. self::$stInstance->load();
  25. }
  26. }
  27. return self::$stInstance;
  28. }
  29. private function load()
  30. {
  31. $this->mPolicy->load();
  32. }
  33. private function __construct()
  34. {
  35. parent::__construct();
  36. $this->mPolicy = new policy();
  37. if (defined('SUPPORT_PTHREAD') && SUPPORT_PTHREAD === true) {
  38. Log::record("SUPPORT_PTHREAD defined dont call load",Log::DEBUG);
  39. } else {
  40. Log::record("SUPPORT_PTHREAD has not defined and call load",Log::DEBUG);
  41. $this->load();
  42. }
  43. }
  44. }