]> git.mxchange.org Git - core.git/commitdiff
State (see State Pattern) prepared, a lot reworked/refactured
authorRoland Häder <roland@mxchange.org>
Tue, 11 Aug 2009 21:17:24 +0000 (21:17 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 11 Aug 2009 21:17:24 +0000 (21:17 +0000)
- New interfaces and exceptions added for states
- Dead-loop fixed (was caused by previous refacturing
- Misc cleanups/fixes

27 files changed:
.gitattributes
inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php
inc/classes/exceptions/io/class_InvalidResourceException.php [new file with mode: 0644]
inc/classes/exceptions/state/.htaccess [new file with mode: 0644]
inc/classes/exceptions/state/class_InvalidStateException.php [new file with mode: 0644]
inc/classes/interfaces/resolver/state/.htaccess [new file with mode: 0644]
inc/classes/interfaces/resolver/state/class_StateResolver.php [new file with mode: 0644]
inc/classes/interfaces/state/.htaccess [new file with mode: 0644]
inc/classes/interfaces/state/class_Stateable.php [new file with mode: 0644]
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/commands/web/class_WebResendLinkCommand.php
inc/classes/main/crypto/class_CryptoHelper.php
inc/classes/main/database/class_BaseDatabaseFrontend.php
inc/classes/main/database/databases/class_LocalFileDatabase.php
inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php
inc/classes/main/helper/web/links/class_WebLinkHelper.php
inc/classes/main/io/class_FrameworkDirectoryPointer.php
inc/classes/main/io/class_FrameworkFileInputPointer.php
inc/classes/main/io/class_FrameworkFileOutputPointer.php
inc/classes/main/registry/class_Registry.php
inc/classes/main/resolver/class_BaseResolver.php
inc/classes/main/resolver/command/web/class_
inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php
inc/classes/main/resolver/controller/web/class_WebControllerResolver.php
inc/classes/middleware/debug/class_DebugMiddleware.php
inc/loader/class_ClassLoader.php
inc/selector.php

index cdcec144e92bd15ff5fd39b07ed11ab845fa279a..4827646ec5eeb2a23ca164f8b86b50084c73037d 100644 (file)
@@ -63,6 +63,7 @@ inc/classes/exceptions/io/class_FileReadProtectedException.php -text
 inc/classes/exceptions/io/class_InvalidDataLengthException.php -text
 inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php -text
 inc/classes/exceptions/io/class_InvalidMD5ChecksumException.php -text
+inc/classes/exceptions/io/class_InvalidResourceException.php -text
 inc/classes/exceptions/io/class_PathIsEmptyException.php -text
 inc/classes/exceptions/io/class_PathIsNoDirectoryException.php -text
 inc/classes/exceptions/io/class_PathReadProtectedException.php -text
@@ -103,6 +104,8 @@ inc/classes/exceptions/result/class_InvalidDatabaseResultException.php -text
 inc/classes/exceptions/result/class_ResultUpdateException.php -text
 inc/classes/exceptions/socket/.htaccess -text
 inc/classes/exceptions/socket/class_InvalidSocketException.php -text
+inc/classes/exceptions/state/.htaccess -text
+inc/classes/exceptions/state/class_InvalidStateException.php -text
 inc/classes/exceptions/template/.htaccess -text
 inc/classes/exceptions/template/class_BasePathIsEmptyException.php -text
 inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php -text
@@ -199,11 +202,15 @@ inc/classes/interfaces/resolver/commands/.htaccess -text
 inc/classes/interfaces/resolver/commands/class_CommandResolver.php -text
 inc/classes/interfaces/resolver/controller/.htaccess -text
 inc/classes/interfaces/resolver/controller/class_ControllerResolver.php -text
+inc/classes/interfaces/resolver/state/.htaccess -text
+inc/classes/interfaces/resolver/state/class_StateResolver.php -text
 inc/classes/interfaces/response/.htaccess -text
 inc/classes/interfaces/response/class_Responseable.php -text
 inc/classes/interfaces/result/.htaccess -text
 inc/classes/interfaces/result/class_SearchableResult.php -text
 inc/classes/interfaces/result/class_UpdateableResult.php -text
+inc/classes/interfaces/state/.htaccess -text
+inc/classes/interfaces/state/class_Stateable.php -text
 inc/classes/interfaces/streams/.htaccess -text
 inc/classes/interfaces/streams/class_Streamable.php -text
 inc/classes/interfaces/streams/crypto/.htaccess -text
index f0430782ae6ba67cb69f664eb65313f55f4586f4..84994342c146ee36e032c4be1e919910c50c9d1b 100644 (file)
@@ -7,6 +7,8 @@
  * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
+ * @deprecated
+ * @see                        InvalidResourceException
  * 
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/inc/classes/exceptions/io/class_InvalidResourceException.php b/inc/classes/exceptions/io/class_InvalidResourceException.php
new file mode 100644 (file)
index 0000000..7546920
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/**
+ * An exception thrown when a given resource is invalid
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ * 
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class InvalidResourceException extends FrameworkException {
+       /**
+        * The constructor
+        *
+        * @param       $class  Class throwing this exception
+        * @param       $code   Code number for the exception
+        * @return      void
+        */
+       public function __construct (FrameworkInterface $class, $code) {
+               // Add a message around the missing class
+               $message = sprintf("[%s:%d] Has an invalid resource.",
+                       $class->__toString(),
+                       $this->getLine()
+               );
+
+               // Call parent constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/exceptions/state/.htaccess b/inc/classes/exceptions/state/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/exceptions/state/class_InvalidStateException.php b/inc/classes/exceptions/state/class_InvalidStateException.php
new file mode 100644 (file)
index 0000000..1aeefef
--- /dev/null
@@ -0,0 +1,450 @@
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * This exception is thrown when the default state is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class InvalidStateException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $msgArray       An array with message parts
+        * @param       $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Prepare the message
+               $message = sprintf("[%s:%d] Cannot resolve state <span class=\"exception_reason\">%s (class name: %s)</span>.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
+               );
+
+               // Set extra data
+               $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
+
+               // Call parent contructor with message
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/interfaces/resolver/state/.htaccess b/inc/classes/interfaces/resolver/state/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/resolver/state/class_StateResolver.php b/inc/classes/interfaces/resolver/state/class_StateResolver.php
new file mode 100644 (file)
index 0000000..cb882c1
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/**
+ * An instance for state resolver classes
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface StateResolver extends Resolver {
+       /**
+        * Returns an state instance for a given package class and raw data
+        *
+        * @param       $packageInstance        An instance of a package class
+        * @param       $rawData                        The raw data to handle
+        * @return      $stateInstance          An instance of the resolved state
+        */
+       function resolveStateByPackage (Networkable $packageInstance, $rawData);
+
+       /**
+        * Checks wether the given state is valid
+        *
+        * @param       $stateName      The default state we shall execute
+        * @return      $isValid        Wether the given state is valid
+        * @throws      EmptyVariableException  Thrown if given state is not set
+        */
+       function isStateValid ($stateName);
+}
+
+//
+?>
diff --git a/inc/classes/interfaces/state/.htaccess b/inc/classes/interfaces/state/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/state/class_Stateable.php b/inc/classes/interfaces/state/class_Stateable.php
new file mode 100644 (file)
index 0000000..c6621fd
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+ * A Stateable interface
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface Stateable extends FrameworkInterface {
+}
+
+//
+?>
index 9e7f247b4bf131264ce6c8e6a7dc0d0ae20a9b55..e15af40017603d2c5fddc56df98c467b07eeae18 100644 (file)
@@ -128,7 +128,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        const EXCEPTION_WRITE_PROTECED_PATH          = 0x018;
        const EXCEPTION_DIR_POINTER_INVALID          = 0x019;
        const EXCEPTION_FILE_POINTER_INVALID         = 0x01a;
-       const EXCEPTION_INVALID_DIRECTORY_POINTER    = 0x01b;
+       const EXCEPTION_INVALID_RESOURCE             = 0x01b;
        const EXCEPTION_UNEXPECTED_OBJECT            = 0x01c;
        const EXCEPTION_LIMIT_ELEMENT_IS_UNSUPPORTED = 0x01d;
        const EXCEPTION_GETTER_IS_MISSING            = 0x01e;
@@ -171,10 +171,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Set real class
                $this->setRealClass($className);
 
-               // Initialize the class if class Registry is there
-               if ((class_exists('Registry')) && (Registry::isInitialized() === false)) {
-                       // Initialize the registry automatically
-                       $this->initInstance();
+               // Set configuration instance if no registry
+               if (!$this instanceof Register) {
+                       // Because registries doesn't need to be configured
+                       $this->setConfigInstance(FrameworkConfiguration::getInstance());
                } // END - if
        }
 
@@ -245,16 +245,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                return null;
        }
 
-       /**
-        * Private initializer for this class
-        *
-        * @return      void
-        */
-       private final function initInstance () {
-               // Set configuration instance
-               $this->setConfigInstance(FrameworkConfiguration::getInstance());
-       }
-
        /**
         * Setter for database result instance
         *
@@ -388,7 +378,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $debugInstance  Instance to class DebugConsoleOutput or DebugWebOutput
         */
        public final function getDebugInstance () {
+               // Get debug instance
                $debugInstance = Registry::getRegistry()->getInstance('debug');
+
+               // Return it
                return $debugInstance;
        }
 
@@ -429,13 +422,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $dbInstance     The database layer instance
         */
        public final function getDatabaseInstance () {
-               // Default is invalid db instance
-               $dbInstance = null;
-
-               // Is the registry there and initialized?
-               if ((class_exists('Registry')) && (Registry::isInitialized() === true)) {
-                       $dbInstance = Registry::getRegistry()->getInstance('db_instance');
-               } // END - if
+               // Get instance
+               $dbInstance = Registry::getRegistry()->getInstance('db_instance');
 
                // Return instance
                return $dbInstance;
index 73aa5350b49d60775f9cf66c83625b4eacac5604..633a201650293ab3ec60a03a9c38e80e3b150024 100644 (file)
@@ -55,18 +55,11 @@ class WebResendLinkCommand extends BaseCommand implements Commandable {
         * @param       $requestInstance        An instance of a class with an Requestable interface
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
-        * @throws      InvalidInterfaceException       If the user class does not implement ManageableMember
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get user instance from registry
                $userInstance = Registry::getRegistry()->getInstance('user');
 
-               // Does the user instance implement ManageableMember?
-               if (!$userInstance instanceof ManageableMember) {
-                       // Throw exception here
-                       throw new InvalidInterfaceException(array($userInstance, 'ManageableMember'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
-               } // END - if
-
                // Get an application instance
                $appInstance = $this->getResolverInstance()->getApplicationInstance();
 
index cbac7d7b19c641db64f24128b09abe2f007f0f21..db35284416ecb4011caa28f565c43f455dfcc56d 100644 (file)
@@ -183,7 +183,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         */
        public function encryptString ($str) {
                // Encrypt the string through the stream
-               $encryted = $this->cryptoStreamInstance->encryptStream($str);
+               $encrypted = $this->cryptoStreamInstance->encryptStream($str);
 
                // Return the string
                return $encrypted;
index 514b8ec6118d5a35e64d0682af7c5dcf19fc5d74..bc1c7f61c5d271bbac223f706121574c5562b48c 100644 (file)
@@ -40,9 +40,6 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implements Datab
        protected function __construct ($className) {
                // Call parent constructor
                parent::__construct($className);
-
-               // Clean up a little
-               $this->removeNumberFormaters();
        }
 }
 
index d4c45e972eaa9b04c03f8de6b5e3fcc190597c26..1298ff8b4fe59ab4a9524b99c5519d0958f47c92 100644 (file)
@@ -99,17 +99,23 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         */
        public final static function createLocalFileDatabase ($savePath, FileIoHandler $ioInstance) {
                // Get an instance
-               $dbInstance = new LocalFileDatabase();
+               $databaseInstance = new LocalFileDatabase();
 
                // Set save path and IO instance
-               $dbInstance->setSavePath($savePath);
-               $dbInstance->setFileIoInstance($ioInstance);
+               $databaseInstance->setSavePath($savePath);
+               $databaseInstance->setFileIoInstance($ioInstance);
+
+               // Set the compressor channel
+               $databaseInstance->setCompressorChannel(CompressorChannel::createCompressorChannel(
+                       $databaseInstance->getConfigInstance()->getConfigEntry('base_path').
+                       $databaseInstance->getConfigInstance()->getConfigEntry('compressor_base_path')
+               ));
 
                // "Connect" to the database
-               $dbInstance->connectToDatabase();
+               $databaseInstance->connectToDatabase();
 
                // Return database instance
-               return $dbInstance;
+               return $databaseInstance;
        }
 
        /**
@@ -119,11 +125,8 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         * @return      void
         */
        public final function setSavePath ($savePath) {
-               // Secure string
-               $savePath = (string) $savePath;
-
                // Set save path
-               $this->savePath = $savePath;
+               $this->savePath = (string) $savePath;
        }
 
        /**
index 7702aabcfd58e1f035de4af963968a89ed3212af..6086de89706b5d70fafd4c82e85005d0f3c075cf 100644 (file)
@@ -51,7 +51,6 @@ class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable {
         * @param       $requestInstance        An instance of a class with an Requestable interface
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
-        * @throws      NullPointerException    If the user instance from registry is null
         * @throws      FilterChainException    If this filter fails to operate
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
@@ -82,12 +81,6 @@ class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable {
                // Get a user instance from registry
                $userInstance = Registry::getRegistry()->getInstance('user');
 
-               // Is the instance there?
-               if (is_null($userInstance)) {
-                       // Throw an exception here
-                       throw new NullPointerException ($this, self::EXCEPTION_IS_NULL_POINTER);
-               } // END - if
-
                // Get the confirm code from user for comparison
                $userCode = $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH);
 
index 484d2fe6bff4d229e0438de81b36d42f7a29b7c3..69eeb7e9983aed05db70acbea24f5bd8c68b624d 100644 (file)
@@ -59,7 +59,6 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate {
         * @param       $linkName                       Name of the link we shall generate
         * @param       $linkBase                       Link base for the link. This parameter is deprecated.
         * @return      $helperInstance         A prepared instance of this helper
-        * @throws      NullPointerException    Thrown if an instance is null
         * @throws      ConfigEntryNotFoundException    A deprecated exception at this point
         */
        public final static function createWebLinkHelper (CompileableTemplate $templateInstance, $linkName, $linkBase = null) {
@@ -75,12 +74,6 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate {
                // Get the application instance
                $applicationInstance = Registry::getRegistry()->getInstance('application');
 
-               // Sanity-check on it
-               if (is_null($applicationInstance)) {
-                       // Throw an exception here
-                       throw new NullPointerException($helperInstance, self::EXCEPTION_IS_NULL_POINTER);
-               } // END - if
-
                // Get the request instance
                $requestInstance = $applicationInstance->getRequestInstance();
 
index 98fe305abe1bfd7f8a33e5f759efa6d79c16bf06..c25e97bb9f7a1a7bca0b113cdb3b3529040c0e36 100644 (file)
@@ -196,7 +196,7 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem {
                        $this->dirPointer = $dirPointer;
                } else {
                        // Throw exception
-                       throw new InvalidDirectoryResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
                }
        }
 
index 7f4466cea10ccb407f36d84d7e16e272d2469c7c..b296421bfbdcb86474f037db8dfc2764bb90bf35 100644 (file)
@@ -105,7 +105,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
         * @return      mixed   The result of fread()
         * @throws      NullPointerException    If the file pointer instance
         *                                                                      is not set by setPointer()
-        * @throws      InvalidFileResourceException    If there is being set
+        * @throws      InvalidResourceException        If there is being set
         *                                                                      an invalid file resource
         */
        public function readFromFile () {
@@ -114,7 +114,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_resource($this->getPointer())) {
                        // Pointer is not a valid resource!
-                       throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
                }
 
                // Read data from the file pointer and return it
@@ -127,7 +127,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
         * @return      mixed   The result of fread()
         * @throws      NullPointerException    If the file pointer instance
         *                                                                      is not set by setPointer()
-        * @throws      InvalidFileResourceException    If there is being set
+        * @throws      InvalidResourceException        If there is being set
         *                                                                      an invalid file resource
         */
        public function readLinesFromFile () {
@@ -136,7 +136,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_resource($this->getPointer())) {
                        // Pointer is not a valid resource!
-                       throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
                }
 
                // Read data from the file pointer and return it
@@ -150,7 +150,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
         * @return      void
         * @throws      NullPointerException    If the file pointer instance
         *                                                                      is not set by setPointer()
-        * @throws      InvalidFileResourceException    If there is being set
+        * @throws      InvalidResourceException        If there is being set
         */
        public function closeFile () {
                if (is_null($this->getPointer())) {
@@ -158,7 +158,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_resource($this->getPointer())) {
                        // Pointer is not a valid resource!
-                       throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
                }
 
                // Close the file pointer and reset the instance variable
@@ -180,7 +180,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem {
                        $this->filePointer = $filePointer;
                } else {
                        // Throw exception
-                       throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
                }
        }
 
index 8ea8a0d189dba6f7e07539ead08f5e13019f8c04..bc69bea5ea240eb053a29c4ae0b60666cfdb2414 100644 (file)
@@ -97,7 +97,7 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem {
         * @return      mixed                   The result of fwrite()
         * @throws      NullPointerException    If the file pointer instance
         *                                                                      is not set by setPointer()
-        * @throws      InvalidFileResourceException    If there is being set
+        * @throws      InvalidResourceException        If there is being set
         *                                                                                      an invalid file resource
         */
        public function writeToFile ($dataStream) {
@@ -106,7 +106,7 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem {
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_resource($this->getPointer())) {
                        // Pointer is not a valid resource!
-                       throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
                }
 
                // Read data from the file pointer and return it
@@ -120,7 +120,7 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem {
         * @return      void
         * @throws      NullPointerException    If the file pointer instance
         *                                                                      is not set by setPointer()
-        * @throws      InvalidFileResourceException    If there is being set
+        * @throws      InvalidResourceException        If there is being set
         */
        public function closeFile () {
                if (is_null($this->getPointer())) {
@@ -128,7 +128,7 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem {
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_resource($this->getPointer())) {
                        // Pointer is not a valid resource!
-                       throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
                }
 
                // Close the file pointer and reset the instance variable
@@ -150,7 +150,7 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem {
                        $this->filePointer = $filePointer;
                } else {
                        // Throw exception
-                       throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
                }
        }
 
index 876f7e380edb6d5be4cbb2a8fea963d6aae70cad..35867f05fdab7257e7a979923ce044a166a9eb40 100644 (file)
@@ -28,11 +28,6 @@ class Registry extends BaseFrameworkSystem implements Register {
         */
        private static $registryInstance = null;
 
-       /**
-        * Wether the registry is initialized
-        */
-       private static $initialized = false;
-
        /**
         * Instance registry
         */
@@ -65,26 +60,6 @@ class Registry extends BaseFrameworkSystem implements Register {
                return self::$registryInstance;
        }
 
-       /**
-        * Checks or sets wether the registry has been initialized. This had only
-        * be done once.
-        *
-        * @param       $initialized    Wether the registry is initialized
-        * @return      $initialized    Wether the registry is initialized
-        */
-       public final static function isInitialized ($initialized = null) {
-               // If no parameter (null by default) is provided we want to get the
-               // parameter. If set to e.g. 'OK' then the registry is set to
-               // "initialized".
-               if (is_null($initialized)) {
-                       // Get status if initialized
-                       return self::$initialized;
-               } else {
-                       // Registry is initialized!
-                       self::$initialized = true;
-               }
-       }
-
        /**
         * Checks wether an instance key was found
         *
@@ -115,6 +90,7 @@ class Registry extends BaseFrameworkSystem implements Register {
         *
         * @param       $instanceKey            The key to identify the instance
         * @return      $objectInstance         An instance we shall store
+        * @throws      NullPointerException    If the requested key is not found
         */
        public function getInstance ($instanceKey) {
                // By default the instance is not in registry
@@ -125,6 +101,12 @@ class Registry extends BaseFrameworkSystem implements Register {
                        $objectInstance = $this->instanceRegistry[$instanceKey];
                } // END - if
 
+               // Still not fetched?
+               if (is_null($objectInstance)) {
+                       // This might happen if a non-registered key was requested
+                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+               } // END - if
+
                // Return the result
                return $objectInstance;
        }
index d15ef3108cb0ba5d43d9ddb23090819c94a1d3ef..c485a619d36fb4945212402e2ba53e0733382dc6 100644 (file)
@@ -31,6 +31,7 @@ class BaseResolver extends BaseFrameworkSystem {
        const EXCEPTION_INVALID_COMMAND    = 0x1d0;
        const EXCEPTION_INVALID_CONTROLLER = 0x1d1;
        const EXCEPTION_INVALID_ACTION     = 0x1d2;
+       const EXCEPTION_INVALID_STATE      = 0x1d3;
 
        /**
         * Protected constructor
index 2f6a2b371d9a5a40bba568b686f5cf10f36e460a..57955f976afaf0e613d176b1a60b65a325675ba4 100644 (file)
@@ -36,8 +36,8 @@ class Web???CommandResolver extends BaseCommandResolver implements CommandResolv
                // Call parent constructor
                parent::__construct(__CLASS__);
 
-               // Set prefix to "Web"
-               $this->setCommandPrefix("Web");
+               // Set prefix to 'Web'
+               $this->setCommandPrefix('Web');
        }
 
        /**
index fea3a8263cf26f903bf51584285a61cbe811e962..7cbdfbc0ee05b044f508120a876ce721f41b5618 100644 (file)
@@ -41,8 +41,8 @@ class ImageControllerResolver extends BaseControllerResolver implements Controll
                // Call parent constructor
                parent::__construct(__CLASS__);
 
-               // Set prefix to "Image"
-               $this->setControllerPrefix("Image");
+               // Set prefix to 'Image'
+               $this->setControllerPrefix('Image');
        }
 
        /**
index b43274d3e3a16e876e2fc815acbfeafd0106d3a0..5cf6b41794dae94b268043d22f64a6f7d76b06cb 100644 (file)
@@ -41,8 +41,8 @@ class WebControllerResolver extends BaseControllerResolver implements Controller
                // Call parent constructor
                parent::__construct(__CLASS__);
 
-               // Set prefix to "Web"
-               $this->setControllerPrefix("Web");
+               // Set prefix to 'Web'
+               $this->setControllerPrefix('Web');
        }
 
        /**
index dec9b06f2e626dcb72f9363a74959d447d8d5296..e79459866e35d872982c181cb9c37dc7e88048d8 100644 (file)
@@ -45,6 +45,9 @@ class DebugMiddleware extends BaseMiddleware implements Registerable {
 
                // Set own instance
                self::$thisInstance = $this;
+
+               // Set it so all can use it
+               $this->setDebugInstance($this);
        }
 
        /**
index 97a477e53abd917e4407e9f0b49a51f292f70da6..06e1b1ddfa9b7071995c9c020397fa8e953a84fa 100644 (file)
@@ -228,23 +228,6 @@ class ClassLoader {
                } // END - if
        }
 
-       /**
-        * Fall-back method. Please replace loadClasses() with scanClassPath() !
-        *
-        * @param       $basePath               The relative base path to 'base_path' constant for all classes
-        * @param       $ignoreList             An optional list (array forced) of directory and file names which shall be ignored
-        * @return      void
-        * @deprecated
-        * @todo        Rewrite your apps to scanClassPath()
-        */
-       public function loadClasses ($basePath, array $ignoreList = array() ) {
-               // This outputs an ugly message because you need to change to scanClassPath
-               print __METHOD__." is deprecated. Use scanClassPath() to make this warning go away.<br />\n";
-
-               // Call our new method
-               $this->scanClassPath($basePath, $ignoreList);
-       }
-
        /**
         * Scans recursively a local path for class files which must have a prefix and a suffix as given by $this->suffix and $this->prefix
         *
index a441dafcd793f94fb94b819515ae46583857a996..1898557928e653b332801a047499dfcb073d0bcc 100644 (file)
 // Try to load these includes in the given order
 $configAppIncludes = array(
        'class_' . FrameworkConfiguration::getInstance()->getConfigEntry('app_helper_class'), // The ApplicationHelper class
+       'debug',                // Some debugging stuff
+       'exceptions',   // The application's own exception handler
+       'loader',               // The application's class loader
        'config',               // The application's own configuration
        'data',                 // Application data
        'init',                 // The application initializer
-       'loader',               // The application's class loader
-       'debug',                // Some debugging stuff
-       'exceptions',   // The application's own exception handler
        'starter',              // The application starter (calls entryPoint(), etc.)
 );