X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fclass_BaseFrameworkSystem.php;h=6cc07b23a42816073734a0df3b6d8adb36966fe4;hp=9ef0a809107303e908594b27bd6f5553eff4cf50;hb=fde621572cc9737972c2305644a6e847562b6140;hpb=99918e8d052600e168a8945b015c27e3f12a7165 diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 9ef0a809..6cc07b23 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -5,7 +5,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -108,10 +108,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ private $compressorInstance = null; + /** + * A Parseable instance + */ + private $parserInstance = null; + + /** + * A ProtocolHandler instance + */ + private $protocolInstance = null; + + /** + * A database wrapper instance + */ + private $databaseInstance = null; + /** * The real class name */ - private $realClass = 'BaseFrameworkSystem'; + private $realClass = 'BaseFrameworkSystem'; /** * Thousands seperator @@ -123,6 +138,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ private $decimals = ','; // German + /** + * Socket resource + */ + private $socketResource = false; + + /** + * Package data + */ + private $packageData = array(); + /*********************** * Exception codes.... * ***********************/ @@ -172,8 +197,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { const EXCEPTION_ATTRIBUTES_ARE_MISSING = 0x02b; const EXCEPTION_ARRAY_ELEMENTS_MISSING = 0x02c; const EXCEPTION_TEMPLATE_ENGINE_UNSUPPORTED = 0x02d; - const EXCEPTION_MISSING_LANGUAGE_HANDLER = 0x02e; - const EXCEPTION_MISSING_FILE_IO_HANDLER = 0x02f; const EXCEPTION_MISSING_ELEMENT = 0x030; const EXCEPTION_HEADERS_ALREADY_SENT = 0x031; const EXCEPTION_DEFAULT_CONTROLLER_GONE = 0x032; @@ -350,7 +373,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { /** * Setter for resolver instance * - * @param $resolverInstance Instance of a command resolver class + * @param $resolverInstance Instance of a command resolver class * @return void */ public final function setResolverInstance (Resolver $resolverInstance) { @@ -360,7 +383,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { /** * Getter for resolver instance * - * @return $resolverInstance Instance of a command resolver class + * @return $resolverInstance Instance of a command resolver class */ public final function getResolverInstance () { return $this->resolverInstance; @@ -433,8 +456,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { /** * Setter for database instance * - * @param $dbInstance The instance for the database connection - * (forced DatabaseConnection) + * @param $dbInstance The instance for the database connection (forced DatabaseConnection) * @return void */ public final function setDatabaseInstance (DatabaseConnection $dbInstance) { @@ -537,7 +559,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * * @return $realClass The name of the real class (not BaseFrameworkSystem) */ - public final function __toString () { + public function __toString () { return $this->realClass; } @@ -571,7 +593,18 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { )); // Return the result - return $result; + return $equals; + } + + /** + * Generates a generic hash code of this class. You should really overwrite + * this method with your own hash code generator code. But keep KISS in mind. + * + * @return $hashCode A generic hash code respresenting this whole class + */ + public function hashCode () { + // Simple hash code + return crc32($this->__toString()); } /** @@ -591,7 +624,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if ((!isset($this->decimals)) || (!isset($this->thousands))) { // Throw an exception throw new MissingDecimalsThousandsSeperatorException($this, self::EXCEPTION_ATTRIBUTES_ARE_MISSING); - } + } // END - if // Cast the number $value = (float) $value; @@ -632,7 +665,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ public final function addMissingTrailingSlash ($str) { // Is there a trailing slash? - if (substr($str, -1, 1) != '/') $str .= '/'; + if (substr($str, -1, 1) != '/') { + $str .= '/'; + } // END - if + + // Return string with trailing slash return $str; } @@ -659,42 +696,27 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * Prepare the template engine (WebTemplateEngine by default) for a given * application helper instance (ApplicationHelper by default). * - * @param $appInstance An application helper instance or + * @param $applicationInstance An application helper instance or * null if we shall use the default - * @return $templateInstance The template engine instance - * @throws NullPointerException If the template engine could not - * be initialized - * @throws UnsupportedTemplateEngineException If $templateInstance is an - * unsupported template engine - * @throws MissingLanguageHandlerException If the language sub-system - * is not yet initialized + * @return $templateInstance The template engine instance * @throws NullPointerException If the discovered application * instance is still null */ - protected function prepareTemplateInstance (FrameworkInterface $appInstance=null) { + protected function prepareTemplateInstance (ManageableApplication $applicationInstance = null) { // Is the application instance set? - if (is_null($appInstance)) { + if (is_null($applicationInstance)) { // Get the current instance - $appInstance = $this->getApplicationInstance(); + $applicationInstance = $this->getApplicationInstance(); // Still null? - if (is_null($appInstance)) { + if (is_null($applicationInstance)) { // Thrown an exception throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } // END - if } // END - if - // Are both instances set? - if ($appInstance->getLanguageInstance() === null) { - // Invalid language instance - throw new MissingLanguageHandlerException($appInstance, self::EXCEPTION_MISSING_LANGUAGE_HANDLER); - } elseif ($appInstance->getFileIoInstance() === null) { - // Invalid language instance - throw new MissingFileIoHandlerException($appInstance, self::EXCEPTION_MISSING_FILE_IO_HANDLER); - } - // Initialize the template engine - $templateInstance = ObjectFactory::createObjectByConfiguredName('web_template_class', array($appInstance)); + $templateInstance = ObjectFactory::createObjectByConfiguredName('web_template_class'); // Return the prepared instance return $templateInstance; @@ -768,7 +790,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Generate the class::method string $methodName = 'UnknownClass->unknownMethod'; if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) { - $methodName = $backtrace[1]['class']."->".$backtrace[1]['function']; + $methodName = $backtrace[1]['class'] . '->' . $backtrace[1]['function']; } // END - if // Construct the full message @@ -788,7 +810,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $this->debugOutput($stubMessage); } else { // Trigger an error - trigger_error($stubMessage."
\n"); + trigger_error($stubMessage . "
\n"); } } @@ -820,7 +842,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (is_object($debugInstance)) { // Use debug output handler $debugInstance->output($message); - if ($doPrint === false) die(); // Die here if not printed + + if ($doPrint === false) { + // Die here if not printed + die(); + } // END - if } else { // Put directly out if ($doPrint === true) { @@ -1115,7 +1141,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $this->debugOutput($message); } else { // Trigger an error - trigger_error($message."
\n"); + trigger_error($message . "
\n"); } } else { // @TODO Finish this part! @@ -1123,17 +1149,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } } - /** - * Generates a generic hash code of this class. You should really overwrite - * this method with your own hash code generator code. But keep KISS in mind. - * - * @return $hashCode A generic hash code respresenting this whole class - */ - public function hashCode () { - // Simple hash code - return crc32($this->__toString()); - } - /** * Checks wether the given PHP extension is loaded * @@ -1265,7 +1280,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } /** - * Setter for image instanxe + * Setter for image instance * * @param $imageInstance An instance of an image * @return void @@ -1275,7 +1290,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } /** - * Getter for image instanxe + * Getter for image instance * * @return $imageInstance An instance of an image */ @@ -1284,7 +1299,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } /** - * Setter for stacker instanxe + * Setter for stacker instance * * @param $stackerInstance An instance of an stacker * @return void @@ -1294,7 +1309,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } /** - * Getter for stacker instanxe + * Getter for stacker instance * * @return $stackerInstance An instance of an stacker */ @@ -1303,7 +1318,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } /** - * Setter for compressor instanxe + * Setter for compressor instance * * @param $compressorInstance An instance of an compressor * @return void @@ -1313,13 +1328,108 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } /** - * Getter for compressor instanxe + * Getter for compressor instance * * @return $compressorInstance An instance of an compressor */ public final function getCompressorInstance () { return $this->compressorInstance; } + + /** + * Setter for Parseable instance + * + * @param $parserInstance An instance of an Parseable + * @return void + */ + public final function setParserInstance (Parseable $parserInstance) { + $this->parserInstance = $parserInstance; + } + + /** + * Getter for Parseable instance + * + * @return $parserInstance An instance of an Parseable + */ + public final function getParserInstance () { + return $this->parserInstance; + } + + /** + * Setter for ProtocolHandler instance + * + * @param $protocolInstance An instance of an ProtocolHandler + * @return void + */ + public final function setProtocolInstance (ProtocolHandler $protocolInstance) { + $this->protocolInstance = $protocolInstance; + } + + /** + * Getter for ProtocolHandler instance + * + * @return $protocolInstance An instance of an ProtocolHandler + */ + public final function getProtocolInstance () { + return $this->protocolInstance; + } + + /** + * Setter for BaseDatabaseWrapper instance + * + * @param $wrapperInstance An instance of an BaseDatabaseWrapper + * @return void + */ + public final function setWrapperInstance (BaseDatabaseWrapper $wrapperInstance) { + $this->wrapperInstance = $wrapperInstance; + } + + /** + * Getter for BaseDatabaseWrapper instance + * + * @return $wrapperInstance An instance of an BaseDatabaseWrapper + */ + public final function getWrapperInstance () { + return $this->wrapperInstance; + } + + /** + * Setter for socket resource + * + * @param $socketResource A valid socket resource + * @return void + */ + public final function setSocketResource ($socketResource) { + $this->socketResource = $socketResource; + } + + /** + * Getter for socket resource + * + * @return $socketResource A valid socket resource + */ + public function getSocketResource () { + return $this->socketResource; + } + + /** + * Setter for raw package Data + * + * @param $packageData Raw package Data + * @return void + */ + public final function setPackageData (array $packageData) { + $this->packageData = $packageData; + } + + /** + * Getter for raw package Data + * + * @return $packageData Raw package Data + */ + public function getPackageData () { + return $this->packageData; + } } // [EOF]