| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 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: | |
| 36: | |
| 37: | |
| 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: | |