1: <?php
2: /**
3: * This code is licensed under AGPLv3 license or Afterlogic Software License
4: * if commercial version of the product was purchased.
5: * For full statements of the licenses see LICENSE-AFTERLOGIC and LICENSE-AGPL3 files.
6: */
7:
8: namespace Aurora\System;
9:
10: /**
11: * @license https://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
12: * @license https://afterlogic.com/products/common-licensing Afterlogic Software License
13: * @copyright Copyright (c) 2019, Afterlogic Corp.
14: *
15: * @package Api
16: */
17: class ObjectExtender
18: {
19: /**
20: * @var array
21: */
22: protected $_aObjects = [];
23:
24: /**
25: *
26: */
27: protected static $self = null;
28:
29: /**
30: *
31: * @return \self
32: */
33: public static function createInstance()
34: {
35: return new self();
36: }
37:
38: /**
39: *
40: * @return ObjectExtender
41: */
42: public static function getInstance()
43: {
44: if (is_null(self::$self)) {
45: self::$self = new self();
46: }
47:
48: return self::$self;
49: }
50:
51: /**
52: *
53: * @param string $sModule
54: * @param string $sType
55: * @param array $aMap
56: */
57: public function extend($sModule, $sType, $aMap)
58: {
59: foreach ($aMap as $sKey => $aValue) {
60: $aValue['@Extended'] = true;
61: $this->_aObjects[$sType][$sModule . Module\AbstractModule::$Delimiter . $sKey] = $aValue;
62: }
63: }
64:
65: /**
66: *
67: * @param string $sType
68: * @return array
69: */
70: public function getObject($sType)
71: {
72: return isset($this->_aObjects[$sType]) ? $this->_aObjects[$sType] : [];
73: }
74:
75: /**
76: *
77: * @param string $sType
78: * @return boolean
79: */
80: public function issetObject($sType)
81: {
82: return isset($this->_aObjects[$sType]);
83: }
84:
85: public function getExtendedProps($sType)
86: {
87: return isset($this->_aObjects[$sType]) ? $this->_aObjects[$sType] : [];
88: }
89: }
90: