1
0

BxDolStudioJson.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaStudio UNA Studio
  7. * @{
  8. */
  9. class BxDolStudioJson extends BxDolFactory implements iBxDolSingleton
  10. {
  11. protected function __construct()
  12. {
  13. if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
  14. trigger_error ('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
  15. parent::__construct ();
  16. }
  17. public function __clone()
  18. {
  19. if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
  20. trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
  21. }
  22. public static function getInstance()
  23. {
  24. if (!isset($GLOBALS['bxDolClasses'][__CLASS__])) {
  25. $GLOBALS['bxDolClasses'][__CLASS__] = new BxDolStudioJson();
  26. }
  27. return $GLOBALS['bxDolClasses'][__CLASS__];
  28. }
  29. public function load($sUrl, $aParams = array())
  30. {
  31. $sContent = bx_file_get_contents($sUrl, $aParams);
  32. if(empty($sContent))
  33. return false;
  34. //echo $sContent; exit; //--- Uncomment to debug
  35. $mixedResult = json_decode($sContent, true);
  36. if(is_null($mixedResult))
  37. return false;
  38. return $mixedResult;
  39. }
  40. }
  41. /** @} */