class_ImageControllerResolver.php
Go to the documentation of this file.00001 <?php
00024 class ImageControllerResolver extends BaseControllerResolver implements ControllerResolver {
00028 private $lastControllerName = "";
00029
00033 private $lastControllerInstance = null;
00034
00040 protected function __construct () {
00041
00042 parent::__construct(__CLASS__);
00043
00044
00045 $this->setControllerPrefix("Image");
00046 }
00047
00057 public final static function createImageControllerResolver ($controllerName, ManageableApplication $appInstance) {
00058
00059 $resolverInstance = new ImageControllerResolver();
00060
00061
00062 if (empty($controllerName)) {
00063
00064 throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
00065 } elseif ($resolverInstance->isControllerValid($controllerName) === false) {
00066
00067 throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
00068 }
00069
00070
00071 $resolverInstance->setApplicationInstance($appInstance);
00072
00073
00074 $resolverInstance->setControllerName($controllerName);
00075
00076
00077 return $resolverInstance;
00078 }
00079
00088 public function resolveController () {
00089
00090 $controllerName = "";
00091 $controllerInstance = null;
00092
00093
00094 $controllerName = $this->getControllerName();
00095
00096
00097 $controllerInstance = $this->loadController($controllerName);
00098
00099
00100 if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
00101
00102 throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
00103 }
00104
00105
00106 $this->lastControllerInstance = $controllerInstance;
00107
00108
00109 return $controllerInstance;
00110 }
00111
00122 private function loadController ($controllerName) {
00123
00124 $defaultController = $this->getConfigInstance()->readConfig('default_image_command');
00125
00126
00127 $controllerInstance = null;
00128
00129
00130 $this->setClassName($defaultController);
00131
00132
00133
00134 if ($controllerName != $defaultController) {
00135
00136 $this->setClassName(sprintf("Image%sController",
00137 $this->convertToClassName($controllerName)
00138 ));
00139 }
00140
00141
00142
00143 if (!class_exists($this->getClassName())) {
00144
00145 throw new InvalidControllerException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
00146 }
00147
00148
00149 $resolverInstance = ObjectFactory::createObjectByConfiguredName('image_cmd_resolver_class', array($controllerName, $this->getApplicationInstance()));
00150 $controllerInstance = ObjectFactory::createObjectByName($this->getClassName(), array($resolverInstance));
00151
00152
00153 unset($resolverInstance);
00154
00155
00156 return $controllerInstance;
00157 }
00158 }
00159
00160
00161 ?>