]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/main/ships/class_BaseShip.php
Deprecated methods and exceptions removed
[shipsimu.git] / application / ship-simu / main / ships / class_BaseShip.php
index c4a548b3f8908a66198e26d4fa3ad45a021170b1..c04762792229b0228eb0cc01a9e113a79999ac4d 100644 (file)
@@ -6,7 +6,7 @@
  * @version            0.0.0
  * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @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
@@ -19,7 +19,7 @@
  * 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseShip extends BaseSimulator {
        // Name des Shipes
@@ -38,41 +38,24 @@ class BaseShip extends BaseSimulator {
        private $structures = null;
 
        // Namenloses Ship generieren
-       private function __construct($class) {
+       protected function __construct($class) {
                // Call parent constructor
-               parent::constructor($class);
+               parent::__construct($class);
 
-               // Beim Schiff angelangt
-               if (((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT')))
-                       $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
-                               __CLASS__,
-                               __LINE__
-                       ));
+               // Set object description
+               $this->setObjectDescription("Allgemeines Schiff");
 
-               // Bezeichnung setzen
-               $this->setPartDescr("Schiff");
-
-               // Array-Objekt generieren
+               // Prepare array object for all structures
                $this->createStructuresArray();
 
-               // Instanz entfernen
+               // Clean-up a little
                $this->removePartInstance();
                $this->removeNumberFormaters();
        }
 
-       /**
-        * Calls the private constructor
-        *
-        * @param       $class  The class' name
-        * @return      void
-        */
-       public function constructor ($class) {
-               $this->__construct($class);
-       }
-
        // Array-Objekt anlegen
        private function createStructuresArray () {
-               $this->structures = new FrameworkArrayObject();
+               $this->structures = new FrameworkArrayObject("FakedShipStructures");
        }
 
        // Schiffsteil generieren (kann alles sein)
@@ -88,23 +71,11 @@ class BaseShip extends BaseSimulator {
 
                // Ist die gewuenschte Klasse vorhanden?
                if (class_exists($partClass)) {
-                       // Befehl zusammenbauen
-                       $eval = sprintf("\$partInstance = %s::create%s();",
-                               $partClass, $partClass
-                       );
-
-                       // Debug-Meldung ausgeben
-                       if ((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruierte PHP-Anweisung: <pre><em>%s</em></pre><br />\n",
-                               __CLASS__,
-                               __LINE__,
-                               htmlentities($eval)
-                       ));
-
-                       // ... und ausfuehren
-                       eval($eval);
+                       // Get an instance back from our object factory
+                       $partInstance = ObjectFactory::createObjectByName($partClass);
                } else {
                        // Nicht vorhanden, dann Ausnahme werfen!
-                       throw new ClassNotFoundException($partClass, 0);
+                       throw new ClassNotFoundException($partClass, self::EXCEPTION_CLASS_NOT_FOUND);
                }
 
                // Das Einbauen versuchen...
@@ -151,13 +122,6 @@ class BaseShip extends BaseSimulator {
                                $e->getMessage()
                        ));
                        return false;
-               } catch (ExceptionNotChangedException $e) {
-                       if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Eine Exception wurde nicht ge&auml;ndert. Details: <strong>%s</strong><br />\n",
-                               __CLASS__,
-                               __LINE__,
-                               $e->getMessage()
-                       ));
-                       return false;
                } catch (ExceptionNotFoundException $e) {
                        if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Eine Exception wurde nicht gefunden. Details: <strong>%s</strong><br />\n",
                                __CLASS__,
@@ -175,7 +139,7 @@ class BaseShip extends BaseSimulator {
                        __CLASS__,
                        __LINE__,
                        $this->getShipName(),
-                       $partInstance->getPartDescr()
+                       $partInstance->getObjectDescription()
                ));
 
                // Alles klar!