/** * Get information about view for action * * @return array * @since 0.1 */ private function getViewInfo(AgaviExecutionContainer $container) { $result = array(); $outputType = $this->getContext()->getController()->getOutputType($container->getOutputType()->getName()); $result['view_name'] = $container->getViewName(); $result['output_type'] = $container->getOutputType()->getName(); $result['default_output_type'] = $this->getContext()->getController()->getOutputType()->getName(); $result['has_renders'] = $outputType->hasRenderers(); $result['default_layout_name'] = $outputType->getDefaultLayoutName(); return $result; }
/** * execute this containers view instance * * @return mixed the view's result * * @author David Zülke <*****@*****.**> * @author Felix Gilcher <*****@*****.**> * @since 1.0.0 */ protected function executeView(AgaviExecutionContainer $container) { $outputType = $container->getOutputType()->getName(); $request = $this->context->getRequest(); $viewInstance = $container->getViewInstance(); // $lm->log('View is not cached, executing...'); // view initialization completed successfully $executeMethod = 'execute' . $outputType; if (!is_callable(array($viewInstance, $executeMethod))) { $executeMethod = 'execute'; } $key = $request->toggleLock(); try { $viewResult = $viewInstance->{$executeMethod}($container->getRequestData()); } catch (Exception $e) { // we caught an exception... unlock the request and rethrow! $request->toggleLock($key); throw $e; } $request->toggleLock($key); return $viewResult; }
/** * Pretty-print this exception using a template. * * @param Exception The original exception. * @param AgaviContext The context instance. * @param AgaviResponse The response instance. * * @author David Zülke <*****@*****.**> * @since 1.0.0 */ public static function render(Exception $e, AgaviContext $context = null, AgaviExecutionContainer $container = null) { // exit code is 70, EX_SOFTWARE, according to /usr/include/sysexits.h: http://cvs.opensolaris.org/source/xref/on/usr/src/head/sysexits.h // nice touch: an exception template can change this value :) $exitCode = 70; $exceptions = array(); if (version_compare(PHP_VERSION, '5.3', 'ge')) { // reverse order of exceptions $ce = $e; while ($ce) { array_unshift($exceptions, $ce); $ce = $ce->getPrevious(); } } else { $exceptions[] = $e; } if ($container !== null && $container->getOutputType() !== null && $container->getOutputType()->getExceptionTemplate() !== null) { // an exception template was defined for the container's output type include $container->getOutputType()->getExceptionTemplate(); exit($exitCode); } if ($context !== null && $context->getController() !== null) { try { // check if an exception template was defined for the default output type if ($context->getController()->getOutputType()->getExceptionTemplate() !== null) { include $context->getController()->getOutputType()->getExceptionTemplate(); exit($exitCode); } } catch (Exception $e2) { unset($e2); } } if ($context !== null && AgaviConfig::get('exception.templates.' . $context->getName()) !== null) { // a template was set for this context include AgaviConfig::get('exception.templates.' . $context->getName()); exit($exitCode); } // include default exception template include AgaviConfig::get('exception.default_template'); // bail out exit($exitCode); }