Cache.php
7 years ago
Capability.php
7 years ago
LoginRedirect.php
7 years ago
LogoutRedirect.php
7 years ago
Menu.php
7 years ago
Metabox.php
7 years ago
Post.php
7 years ago
Redirect.php
7 years ago
Route.php
7 years ago
Toolbar.php
7 years ago
Visibility.php
7 years ago
Route.php
84 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 | * API route object |
| 12 | * |
| 13 | * @package AAM |
| 14 | * @author Vasyl Martyniuk <vasyl@vasyltech.com> |
| 15 | */ |
| 16 | class AAM_Core_Object_Route extends AAM_Core_Object { |
| 17 | |
| 18 | /** |
| 19 | * Constructor |
| 20 | * |
| 21 | * @param AAM_Core_Subject $subject |
| 22 | * |
| 23 | * @return void |
| 24 | * |
| 25 | * @access public |
| 26 | */ |
| 27 | public function __construct(AAM_Core_Subject $subject) { |
| 28 | parent::__construct($subject); |
| 29 | |
| 30 | $option = $this->getSubject()->readOption('route'); |
| 31 | |
| 32 | if (empty($option)) { |
| 33 | $option = $this->getSubject()->inheritFromParent('route'); |
| 34 | } else { |
| 35 | $this->setOverwritten(true); |
| 36 | } |
| 37 | |
| 38 | $this->setOption($option); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Check if route is denied |
| 43 | * |
| 44 | * @param string $type REST or XMLRPC |
| 45 | * @param string $route |
| 46 | * @param string $method |
| 47 | * |
| 48 | * @return boolean |
| 49 | * |
| 50 | * @access public |
| 51 | */ |
| 52 | public function has($type, $route, $method = 'POST') { |
| 53 | $options = $this->getOption(); |
| 54 | |
| 55 | return !empty($options[$type][$route][$method]); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Save menu option |
| 60 | * |
| 61 | * @return bool |
| 62 | * |
| 63 | * @access public |
| 64 | */ |
| 65 | public function save($type, $route, $method, $value) { |
| 66 | $option = $this->getOption(); |
| 67 | $option[$type][$route][$method] = $value; |
| 68 | $this->setOption($option); |
| 69 | |
| 70 | return $this->getSubject()->updateOption($this->getOption(), 'route'); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Reset default settings |
| 75 | * |
| 76 | * @return bool |
| 77 | * |
| 78 | * @access public |
| 79 | */ |
| 80 | public function reset() { |
| 81 | return $this->getSubject()->deleteOption('route'); |
| 82 | } |
| 83 | |
| 84 | } |