class_BaseActionResolver.php

Go to the documentation of this file.
00001 <?php
00024 class BaseActionResolver extends BaseResolver {
00028         private $actionPrefix = "";
00029 
00033         private $actionName = "";
00034 
00041         protected function __construct ($className) {
00042                 // Call parent constructor
00043                 parent::__construct($className);
00044         }
00045 
00052         protected final function setActionPrefix ($actionPrefix) {
00053                 $this->actionPrefix = $actionPrefix;
00054         }
00055 
00062         protected final function setActionName ($actionName) {
00063                 $this->actionName = (string) $actionName;
00064         }
00065 
00071         public final function getActionName () {
00072                 return $this->actionName;
00073         }
00074 
00082         public function isActionValid ($actionName) {
00083                 // By default nothing shall be valid
00084                 $isValid = false;
00085 
00086                 // Is a action set?
00087                 if (empty($actionName)) {
00088                         // Then thrown an exception here
00089                         throw new EmptyVariableException(array($this, 'actionName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
00090                 } // END - if
00091 
00092                 // Now, let us create the full name of the action class
00093                 $this->setClassName(sprintf("%s%sAction",
00094                         $this->actionPrefix,
00095                         $this->convertToClassName($actionName)
00096                 ));
00097 
00098                 // Is this class already loaded?
00099                 if (class_exists($this->getClassName())) {
00100                         // This class does exist. :-)
00101                         $isValid = true;
00102                 } // END - if
00103 
00104                 // Set action name
00105                 $this->setActionName($actionName);
00106 
00107                 // Return the result
00108                 return $isValid;
00109         }
00110 
00116         protected function loadAction () {
00117                 // Init action instance
00118                 $actionInstance = null;
00119 
00120                 // Create action class name
00121                 $this->setClassName(sprintf("Web%sAction",
00122                         $this->convertToClassName($this->getActionName())
00123                 ));
00124 
00125                 // Initiate the action
00126                 $actionInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this));
00127 
00128                 // Return the result
00129                 return $actionInstance;
00130         }
00131 }
00132 
00133 // [EOF]
00134 ?>

Generated on Mon Dec 8 01:06:46 2008 for Ship-Simulator by  doxygen 1.5.6