class_WebActionResolver.php
Go to the documentation of this file.00001 <?php
00024 class WebActionResolver extends BaseActionResolver implements ActionResolver {
00028 private $lastActionInstance = "";
00029
00035 protected function __construct () {
00036
00037 parent::__construct(__CLASS__);
00038
00039
00040 $this->setActionPrefix("Web");
00041 }
00042
00052 public final static function createWebActionResolver ($actionName, ManageableApplication $appInstance) {
00053
00054 $resolverInstance = new WebActionResolver();
00055
00056
00057 if (empty($actionName)) {
00058
00059 throw new EmptyVariableException(array($resolverInstance, 'defaultAction'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
00060 } elseif ($resolverInstance->isActionValid($actionName) === false) {
00061
00062 throw new InvalidActionException(array($resolverInstance, $actionName), self::EXCEPTION_INVALID_ACTION);
00063 }
00064
00065
00066 $resolverInstance->setApplicationInstance($appInstance);
00067
00068
00069 return $resolverInstance;
00070 }
00071
00083 public function resolveActionByRequest (Requestable $requestInstance) {
00084
00085 $actionName = "";
00086 $actionInstance = null;
00087
00088
00089 $actionName = $requestInstance->getRequestElement('action');
00090
00091
00092 if (empty($actionName)) $actionName = $this->getConfigInstance()->readConfig('default_action');
00093
00094
00095 if ($this->isActionValid($actionName) === false) {
00096
00097 throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION);
00098 }
00099
00100
00101 $actionInstance = $this->loadAction();
00102
00103
00104 if ((!is_object($actionInstance)) || (!$actionInstance instanceof Actionable)) {
00105
00106 throw new InvalidActionInstanceException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION);
00107 }
00108
00109
00110 $this->lastActionInstance = $actionInstance;
00111
00112
00113 return $actionInstance;
00114 }
00115
00122 public function resolveAction () {
00123
00124 $actionInstance = null;
00125
00126
00127 $actionName = $this->getActionName();
00128
00129
00130 if (empty($actionName)) $actionName = $this->getConfigInstance()->readConfig('default_action');
00131
00132
00133 if ($this->isActionValid($actionName) === false) {
00134
00135 throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION);
00136 }
00137
00138
00139 $actionInstance = $this->loadAction();
00140
00141
00142 return $actionInstance;
00143 }
00144 }
00145
00146
00147 ?>