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\Classes;
9:
10: class InheritedAttributes
11: {
12: protected static $attributes = [];
13:
14: public static function addAttributes($model, $attributes)
15: {
16: if (!isset(self::$attributes[$model])) {
17: self::$attributes[$model] = [];
18: }
19: self::$attributes[$model] = array_merge(
20: self::$attributes[$model],
21: $attributes
22: );
23: }
24:
25: public static function getAttributes($model)
26: {
27: if (isset(self::$attributes[$model])) {
28: return self::$attributes[$model];
29: }
30:
31: return [];
32: }
33:
34: /**
35: * @param string $model
36: * @param string $key
37: * @return bool
38: */
39: public static function hasAttribute($model, $key)
40: {
41: if (isset(self::$attributes[$model])) {
42: return in_array($key, self::$attributes[$model]);
43: }
44:
45: return false;
46: }
47: }
48: