Default.php
85 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * ====================================================================== |
| 5 | * LICENSE: This file is subject to the terms and conditions defined in * |
| 6 | * file 'license.txt', which is part of this source code package. * |
| 7 | * ====================================================================== |
| 8 | */ |
| 9 | |
| 10 | /** |
| 11 | * Default subject |
| 12 | * |
| 13 | * @package AAM |
| 14 | * @author Vasyl Martyniuk <vasyl@vasyltech.com> |
| 15 | */ |
| 16 | class AAM_Core_Subject_Default extends AAM_Core_Subject { |
| 17 | |
| 18 | /** |
| 19 | * Subject UID: DEFAULT |
| 20 | */ |
| 21 | const UID = 'default'; |
| 22 | |
| 23 | /** |
| 24 | * |
| 25 | * @var type |
| 26 | */ |
| 27 | protected static $instance = null; |
| 28 | |
| 29 | /** |
| 30 | * |
| 31 | * @param type $value |
| 32 | * @param type $object |
| 33 | * @param type $object_id |
| 34 | * @return type |
| 35 | */ |
| 36 | public function updateOption($value, $object, $object_id = 0) { |
| 37 | return AAM_Core_API::updateOption( |
| 38 | $this->getOptionName($object, $object_id), $value |
| 39 | ); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * |
| 44 | * @param type $object |
| 45 | * @param type $object_id |
| 46 | * @param type $default |
| 47 | * @return type |
| 48 | */ |
| 49 | public function readOption($object, $object_id = 0, $default = null) { |
| 50 | return AAM_Core_API::getOption( |
| 51 | $this->getOptionName($object, $object_id), $default |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * |
| 57 | * @param type $object |
| 58 | * @param type $id |
| 59 | * @return string |
| 60 | */ |
| 61 | public function getOptionName($object, $id) { |
| 62 | return "aam_{$object}" . ($id ? "_{$id}_" : '_') . self::UID; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * |
| 67 | * @return type |
| 68 | */ |
| 69 | public function getUID() { |
| 70 | return self::UID; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * |
| 75 | * @return type |
| 76 | */ |
| 77 | public static function getInstance() { |
| 78 | if (is_null(self::$instance)) { |
| 79 | self::$instance = new self; |
| 80 | } |
| 81 | |
| 82 | return self::$instance; |
| 83 | } |
| 84 | |
| 85 | } |