*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
private $sourceInstance = NULL;
+ /**
+ * An instance of a UrlSource class
+ */
+ private $urlSourceInstance = NULL;
+
/**
* An instance of a InputStream class
*/
* @param $protocolInstance An instance of an HandleableProtocol
* @return void
*/
- public final function setProtocolInstance (HandleableProtocol $protocolInstance = NULL) {
+ public final function setProtocolInstance (HandleableProtocol $protocolInstance) {
$this->protocolInstance = $protocolInstance;
}
/**
* Setter for a Sourceable instance
*
- * @param $sourceInstance The Sourceable instance
+ * @param $sourceInstance An instance of a Sourceable class
* @return void
*/
protected final function setSourceInstance (Sourceable $sourceInstance) {
/**
* Getter for a Sourceable instance
*
- * @return $sourceInstance The Sourceable instance
+ * @return $sourceInstance An instance of a Sourceable class
*/
protected final function getSourceInstance () {
return $this->sourceInstance;
}
+ /**
+ * Setter for a UrlSource instance
+ *
+ * @param $sourceInstance An instance of a UrlSource class
+ * @return void
+ */
+ protected final function setUrlSourceInstance (UrlSource $urlSourceInstance) {
+ $this->urlSourceInstance = $urlSourceInstance;
+ }
+
+ /**
+ * Getter for a UrlSource instance
+ *
+ * @return $urlSourceInstance An instance of a UrlSource class
+ */
+ protected final function getUrlSourceInstance () {
+ return $this->urlSourceInstance;
+ }
+
/**
* Getter for a InputStream instance
*
return $this->pointerInstance;
}
+ /**
+ * Unsets pointer instance which triggers a call of __destruct() if the
+ * instance is still there. This is surely not fatal on already "closed"
+ * file pointer instances.
+ *
+ * I don't want to mess around with above setter by giving it a default
+ * value NULL as setter should always explicitly only set (existing) object
+ * instances and NULL is NULL.
+ *
+ * @return void
+ */
+ protected final function unsetPointerInstance () {
+ // Simply it to NULL
+ $this->pointerInstance = NULL;
+ }
+
/**
* Setter for Indexable instance
*
}
/**
- * Prepare the template engine (WebTemplateEngine by default) for a given
+ * Prepare the template engine (HtmlTemplateEngine by default) for a given
* application helper instance (ApplicationHelper by default).
*
* @param $applicationInstance An application helper instance or
} // END - if
// Initialize the template engine
- $templateInstance = ObjectFactory::createObjectByConfiguredName('web_template_class');
+ $templateInstance = ObjectFactory::createObjectByConfiguredName('html_template_class');
// Return the prepared instance
return $templateInstance;
// Try it
try {
// Get a debugger instance
- $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_class'));
+ $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_' . self::getResponseTypeFromSystem() . '_class'));
} catch (NullPointerException $e) {
// Didn't work, no instance there
exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage());
// Do we have an entry?
if ($this->getResultInstance()->valid() === FALSE) {
- throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), DatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT);
+ // @TODO Move the constant to e.g. BaseDatabaseResult when there is a non-cached database result available
+ throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), CachedDatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT);
} // END - if
// Get next entry
*
* @return $responseType Analyzed response type
*/
- protected function getResponseTypeFromSystem () {
+ protected static function getResponseTypeFromSystem () {
// Default is console
$responseType = 'console';
// Is 'HTTP_HOST' set?
if (isset($_SERVER['HTTP_HOST'])) {
- // Then it is a HTTP response/request
- $responseType = 'http';
+ /*
+ * Then it is a HTML response/request as RSS and so on may be
+ * transfered over HTTP as well.
+ */
+ $responseType = 'html';
} // END - if
// Return it
return $isValid;
}
+ /**
+ * Initializes the web output instance
+ *
+ * @return void
+ */
+ protected function initWebOutputInstance () {
+ // Get application instance
+ $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+ // Is this a response instance?
+ if ($this instanceof Responseable) {
+ // Then set it in application instance
+ $applicationInstance->setResponseInstance($this);
+ } // END - if
+
+ // Init web output instance
+ $outputInstance = ObjectFactory::createObjectByConfiguredName('output_class', array($applicationInstance));
+
+ // Set it locally
+ $this->setWebOutputInstance($outputInstance);
+ }
+
/**
* Translates boolean TRUE to 'Y' and FALSE to 'N'
*