LZRefillFactory.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. use Log;
  8. use StatesHelper;
  9. class LZRefillFactory extends RefillBase
  10. {
  11. private static $stInstance = null;
  12. public static function instance()
  13. {
  14. if (self::$stInstance == null) {
  15. self::$stInstance = new LZRefillFactory();
  16. }
  17. if(defined('SUPPORT_PTHREAD') && SUPPORT_PTHREAD === true)
  18. {
  19. Log::record("SUPPORT_PTHREAD defined call load",Log::DEBUG);
  20. if(StatesHelper::fetch_state('channel')) {
  21. Log::record("RefillFactory reload channel config.",Log::DEBUG);
  22. self::$stInstance->load();
  23. }
  24. }
  25. return self::$stInstance;
  26. }
  27. private function load()
  28. {
  29. $this->mPolicy->load();
  30. }
  31. private function __construct()
  32. {
  33. parent::__construct();
  34. $this->mPolicy = new policy();
  35. if (defined('SUPPORT_PTHREAD') && SUPPORT_PTHREAD === true) {
  36. Log::record("SUPPORT_PTHREAD defined dont call load",Log::DEBUG);
  37. } else {
  38. Log::record("SUPPORT_PTHREAD has not defined and call load",Log::DEBUG);
  39. $this->load();
  40. }
  41. }
  42. }