[Agavi-Commits] r4912 - in branches/david-httpcaching: . src/config/defaults src/controller src/exception

3 views
Skip to first unread message

com...@lists.agavi.org

unread,
Dec 26, 2011, 1:11:00 PM12/26/11
to com...@lists.agavi.org
Author: david
Date: 2011-12-26 19:10:57 +0100 (Mon, 26 Dec 2011)
New Revision: 4912

Added:
branches/david-httpcaching/src/exception/AgaviClassNotFoundException.class.php
branches/david-httpcaching/src/exception/AgaviFileNotFoundException.class.php
Modified:
branches/david-httpcaching/CHANGELOG
branches/david-httpcaching/src/config/defaults/autoload.xml
branches/david-httpcaching/src/controller/AgaviController.class.php
branches/david-httpcaching/src/controller/AgaviExecutionContainer.class.php
Log:
Introduce AgaviClassNotFoundException and AgaviFileNotFoundException, move handling of disabled module and 404 stuff back into AgaviExecutionContainer::execute(), make AgaviController::createEactionInstance() and AgaviController::createViewInstance() use the new exceptions and change their messages to be more descriptive. Concludes the refactoring of action and view instantiation, refs #1398

Modified: branches/david-httpcaching/CHANGELOG
===================================================================
--- branches/david-httpcaching/CHANGELOG 2011-12-26 16:21:02 UTC (rev 4911)
+++ branches/david-httpcaching/CHANGELOG 2011-12-26 18:10:57 UTC (rev 4912)
@@ -22,6 +22,7 @@
ADD: Add support for custom filesystem layouts for modules to the project configuration system (#874) (Noah)
ADD: Response attributes (#1062) (David, TANAKA Koichi)

+CHG: Refactor instantiation of Actions and Views (#1398) (David)
CHG: Remove unlinking of temporary files in AgaviUploadedFile destructor (#1452) (David)
CHG: Overhaul default values in AgaviUploadedFile constructor (#1451) (David)
CHG: Move cleanup and wrapping of uploaded files from AgaviWebRequestDataHolder to AgaviWebRequest (#1450) (David)

Modified: branches/david-httpcaching/src/config/defaults/autoload.xml
===================================================================
--- branches/david-httpcaching/src/config/defaults/autoload.xml 2011-12-26 16:21:02 UTC (rev 4911)
+++ branches/david-httpcaching/src/config/defaults/autoload.xml 2011-12-26 18:10:57 UTC (rev 4912)
@@ -92,12 +92,14 @@
<!-- agavi/exception -->
<autoload class="AgaviAutoloadException">%core.agavi_dir%/exception/AgaviAutoloadException.class.php</autoload>
<autoload class="AgaviCacheException">%core.agavi_dir%/exception/AgaviCacheException.class.php</autoload>
+ <autoload class="AgaviClassNotFoundException">%core.agavi_dir%/exception/AgaviClassNotFoundException.class.php</autoload>
<autoload class="AgaviConfigurationException">%core.agavi_dir%/exception/AgaviConfigurationException.class.php</autoload>
<autoload class="AgaviControllerException">%core.agavi_dir%/exception/AgaviControllerException.class.php</autoload>
<autoload class="AgaviDatabaseException">%core.agavi_dir%/exception/AgaviDatabaseException.class.php</autoload>
<autoload class="AgaviException">%core.agavi_dir%/exception/AgaviException.class.php</autoload>
<autoload class="AgaviFactoryException">%core.agavi_dir%/exception/AgaviFactoryException.class.php</autoload>
<autoload class="AgaviFileException">%core.agavi_dir%/exception/AgaviFileException.class.php</autoload>
+ <autoload class="AgaviFileNotFoundException">%core.agavi_dir%/exception/AgaviFileNotFoundException.class.php</autoload>
<autoload class="AgaviFilterException">%core.agavi_dir%/exception/AgaviFilterException.class.php</autoload>
<autoload class="AgaviInitializationException">%core.agavi_dir%/exception/AgaviInitializationException.class.php</autoload>
<autoload class="AgaviDisabledModuleException">%core.agavi_dir%/exception/AgaviDisabledModuleException.class.php</autoload>

Modified: branches/david-httpcaching/src/controller/AgaviController.class.php
===================================================================
--- branches/david-httpcaching/src/controller/AgaviController.class.php 2011-12-26 16:21:02 UTC (rev 4911)
+++ branches/david-httpcaching/src/controller/AgaviController.class.php 2011-12-26 18:10:57 UTC (rev 4912)
@@ -358,11 +358,11 @@
if(false !== ($file = $this->checkActionFile($moduleName, $actionName))) {
require($file);
} else {
- throw new AgaviException('Could not find file for Action "' . $actionName . '" in module "' . $moduleName . '"');
+ throw new AgaviFileNotFoundException(sprintf('Could not find file for Action "%s" in Module "%s".', $actionName, $moduleName));
}

if(!class_exists($class, false)) {
- throw new AgaviException('Could not find Action "' . $longActionName . '" for module "' . $moduleName . '"');
+ throw new AgaviClassNotFoundException(sprintf('Failed to instantiate Action "%s" in Module "%s" because file "%s" does not contain class "%s".', $actionName, $moduleName, $file, $class));
}
}

@@ -454,11 +454,11 @@
if(false !== ($file = $this->checkViewFile($moduleName, $viewName))) {
require($file);
} else {
- throw new AgaviException('Could not find file for View "' . $viewName . '" in module "' . $moduleName . '"');
+ throw new AgaviFileNotFoundException(sprintf('Could not find file for View "%s" in Module "%s".', $viewName, $moduleName));
}

if(!class_exists($class, false)) {
- throw new AgaviException('Could not find View "' . $longViewName . '" for module "' . $moduleName . '"');
+ throw new AgaviClassNotFoundException(sprintf('Failed to instantiate View "%s" in Module "%s" because file "%s" does not contain class "%s".', $viewName, $moduleName, $file, $class));
}
}

Modified: branches/david-httpcaching/src/controller/AgaviExecutionContainer.class.php
===================================================================
--- branches/david-httpcaching/src/controller/AgaviExecutionContainer.class.php 2011-12-26 16:21:02 UTC (rev 4911)
+++ branches/david-httpcaching/src/controller/AgaviExecutionContainer.class.php 2011-12-26 18:10:57 UTC (rev 4912)
@@ -257,8 +257,17 @@
$controller->countExecution();

$moduleName = $this->getModuleName();
- $actionInstance = $this->getActionInstance();

+ try {
+ $actionInstance = $this->getActionInstance();
+ } catch(AgaviDisabledModuleException $e) {
+ $this->setNext($this->createSystemActionForwardContainer('module_disabled'));
+ return $this->proceed();
+ } catch(AgaviFileNotFoundException $e) {
+ $this->setNext($this->createSystemActionForwardContainer('error_404'));
+ return $this->proceed();
+ } // do not catch AgaviClassNotFoundException, we want that to bubble up since it means the class in the action file is named incorrectly
+
// copy and merge request data as required
$this->initRequestData();

@@ -792,19 +801,7 @@
$moduleName = $this->getModuleName();
$actionName = $this->getActionName();

- try {
- // FIXME: this has been moved from execute(), but in here, the $this->proceed() won't work anymore, and it appears that this whole 404 and module disabled stuff should be put somewhere else anyway. Maybe put the try{}/catch{} into execute()...
- // TODO: cleanup and merge with createActionInstance once Exceptions have been cleaned up and specced properly so that the two error conditions can be told apart
- if(false === $controller->checkActionFile($moduleName, $actionName)) {
- $this->setNext($this->createSystemActionForwardContainer('error_404'));
- return $this->proceed();
- }
-
- $this->actionInstance = $controller->createActionInstance($moduleName, $actionName);
- } catch(AgaviDisabledModuleException $e) {
- $this->setNext($this->createSystemActionForwardContainer('module_disabled'));
- return $this->proceed();
- }
+ $this->actionInstance = $controller->createActionInstance($moduleName, $actionName);

// initialize the action
$this->actionInstance->initialize($this);

Added: branches/david-httpcaching/src/exception/AgaviClassNotFoundException.class.php
===================================================================
--- branches/david-httpcaching/src/exception/AgaviClassNotFoundException.class.php (rev 0)
+++ branches/david-httpcaching/src/exception/AgaviClassNotFoundException.class.php 2011-12-26 18:10:57 UTC (rev 4912)
@@ -0,0 +1,34 @@
+<?php
+
+// +---------------------------------------------------------------------------+
+// | This file is part of the Agavi package. |
+// | Copyright (c) 2005-2011 the Agavi Project. |
+// | |
+// | For the full copyright and license information, please view the LICENSE |
+// | file that was distributed with this source code. You can also view the |
+// | LICENSE file online at http://www.agavi.org/LICENSE.txt |
+// | vi: set noexpandtab: |
+// | Local Variables: |
+// | indent-tabs-mode: t |
+// | End: |
+// +---------------------------------------------------------------------------+
+
+/**
+ * AgaviClassNotFoundException is thrown when a class could not be found.
+ *
+ * @package agavi
+ * @subpackage exception
+ *
+ * @author David Zülke <david....@bitextender.com>
+ * @copyright Authors
+ * @copyright The Agavi Project
+ *
+ * @since 1.1.0
+ *
+ * @version $Id$
+ */
+class AgaviClassNotFoundException extends AgaviException
+{
+}
+
+?>


Property changes on: branches/david-httpcaching/src/exception/AgaviClassNotFoundException.class.php
___________________________________________________________________
Added: svn:keywords
+ Id

Added: branches/david-httpcaching/src/exception/AgaviFileNotFoundException.class.php
===================================================================
--- branches/david-httpcaching/src/exception/AgaviFileNotFoundException.class.php (rev 0)
+++ branches/david-httpcaching/src/exception/AgaviFileNotFoundException.class.php 2011-12-26 18:10:57 UTC (rev 4912)
@@ -0,0 +1,34 @@
+<?php
+
+// +---------------------------------------------------------------------------+
+// | This file is part of the Agavi package. |
+// | Copyright (c) 2005-2011 the Agavi Project. |
+// | |
+// | For the full copyright and license information, please view the LICENSE |
+// | file that was distributed with this source code. You can also view the |
+// | LICENSE file online at http://www.agavi.org/LICENSE.txt |
+// | vi: set noexpandtab: |
+// | Local Variables: |
+// | indent-tabs-mode: t |
+// | End: |
+// +---------------------------------------------------------------------------+
+
+/**
+ * AgaviFileNotFoundException is thrown when a file could not be found.
+ *
+ * @package agavi
+ * @subpackage exception
+ *
+ * @author David Zülke <david....@bitextender.com>
+ * @copyright Authors
+ * @copyright The Agavi Project
+ *
+ * @since 1.1.0
+ *
+ * @version $Id$
+ */
+class AgaviFileNotFoundException extends AgaviException
+{
+}
+
+?>


Property changes on: branches/david-httpcaching/src/exception/AgaviFileNotFoundException.class.php
___________________________________________________________________
Added: svn:keywords
+ Id


_______________________________________________
Agavi Commits Mailing List
com...@lists.agavi.org
http://lists.agavi.org/mailman/listinfo/commits

Reply all
Reply to author
Forward
0 new messages