00001 <?php 00024 class BaseCommandResolver extends BaseResolver { 00028 private $commandPrefix = ""; 00029 00033 private $commandName = ""; 00034 00041 protected function __construct ($className) { 00042 // Call parent constructor 00043 parent::__construct($className); 00044 } 00045 00052 protected final function setCommandPrefix ($commandPrefix) { 00053 $this->commandPrefix = $commandPrefix; 00054 } 00055 00062 protected final function setCommandName ($commandName) { 00063 $this->commandName = $commandName; 00064 } 00065 00071 protected final function getCommandName () { 00072 return $this->commandName; 00073 } 00074 00082 public function isCommandValid ($commandName) { 00083 // By default nothing shall be valid 00084 $isValid = false; 00085 00086 // Is a command set? 00087 if (empty($commandName)) { 00088 // Then thrown an exception here 00089 throw new EmptyVariableException(array($this, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); 00090 } 00091 00092 // Now, let us create the full name of the command class 00093 $this->setClassName(sprintf("%s%sCommand", 00094 $this->commandPrefix, 00095 $this->convertToClassName($commandName) 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 command name 00105 $this->setCommandName($commandName); 00106 00107 // Return the result 00108 return $isValid; 00109 } 00110 } 00111 00112 // [EOF] 00113 ?>
1.5.6