]> git.andy128k.dev Git - ipf-legacy-orm.git/commitdiff
cleanup
authorAndrey Kutejko <andy128k@gmail.com>
Tue, 23 Jul 2013 17:35:42 +0000 (20:35 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Tue, 23 Jul 2013 17:35:42 +0000 (20:35 +0300)
ipf/orm.php
ipf/orm/configurable.php
ipf/orm/connection.php
ipf/orm/manager.php
ipf/orm/table.php

index 68ac5deca41ec6488a9e0631fe9db559715fc563..43bbc49962845b4322bd52ba4483df53c49e135d 100644 (file)
@@ -133,7 +133,6 @@ final class IPF_ORM
     const ATTR_DEFAULT_PARAM_NAMESPACE  = 156;
     const ATTR_QUERY_CACHE              = 157;
     const ATTR_QUERY_CACHE_LIFESPAN     = 158;
-    const ATTR_AUTOLOAD_TABLE_CLASSES   = 160;
     const ATTR_MODEL_LOADING            = 161;
     const ATTR_RECURSIVE_MERGE_FIXTURES = 162;
     const ATTR_SINGULARIZE_IMPORT       = 163;
index e247be8a56dfbd8a74b0124bfa70b3f40331b4b6..887b2b82c1131c7c3fe8238a1ef7b3e6c317432f 100644 (file)
@@ -72,7 +72,6 @@ abstract class IPF_ORM_Configurable extends IPF_ORM_Locator_Injectable
             case IPF_ORM::ATTR_DECIMAL_PLACES:
             case IPF_ORM::ATTR_LOAD_REFERENCES:
             case IPF_ORM::ATTR_DEFAULT_PARAM_NAMESPACE:
-            case IPF_ORM::ATTR_AUTOLOAD_TABLE_CLASSES:
             case IPF_ORM::ATTR_MODEL_LOADING:
             case IPF_ORM::ATTR_RESULT_CACHE_LIFESPAN:
             case IPF_ORM::ATTR_QUERY_CACHE_LIFESPAN:
index fa69f56b0844492fc6246ae6935b2002c73ba06e..06c5306fb260c82652f10a1f5e94d4933c457c7a 100644 (file)
@@ -562,21 +562,9 @@ abstract class IPF_ORM_Connection extends IPF_ORM_Configurable implements Counta
 
     public function getTable($name)
     {
-        if (isset($this->tables[$name])) {
-            return $this->tables[$name];
-        }
-        $class = $name . 'Table';
-
-        if (class_exists($class, $this->getAttribute(IPF_ORM::ATTR_AUTOLOAD_TABLE_CLASSES)) &&
-                in_array('IPF_ORM_Table', class_parents($class))) {
-            $table = new $class($name, $this, true);
-        } else {
-            $table = new IPF_ORM_Table($name, $this, true);
-        }
-
-        $this->tables[$name] = $table;
-
-        return $table;
+        if (!isset($this->tables[$name]))
+            $this->tables[$name] = new IPF_ORM_Table($name, $this);
+        return $this->tables[$name];
     }
 
     public function getTables()
index 9390e9917358241d971e9495e8e5a4b5877c97e0..ddeaaf79b15e78cace860a8732a829d10bdfa251 100644 (file)
@@ -24,7 +24,6 @@ class IPF_ORM_Manager extends IPF_ORM_Configurable implements Countable, Iterato
             IPF_ORM::ATTR_EXPORT                  => IPF_ORM::EXPORT_ALL,
             IPF_ORM::ATTR_DECIMAL_PLACES          => 2,
             IPF_ORM::ATTR_DEFAULT_PARAM_NAMESPACE => 'ipf',
-            IPF_ORM::ATTR_AUTOLOAD_TABLE_CLASSES  => false,
         );
     }
 
index 416102adbf9eee9b7fb19734d4108a9aa1d4e9b2..9cf7cd6cc1909aec84b81503c1171fe769cd475b 100644 (file)
@@ -39,11 +39,10 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable
     protected $_filters     = array();
     protected $_generators     = array();
     protected $_invokedMethods = array();
-    protected $record;
 
     public $listeners = array();
 
-    public function __construct($name, IPF_ORM_Connection $conn, $initDefinition = false)
+    public function __construct($name, IPF_ORM_Connection $conn)
     {
         if (empty($name) || !class_exists($name))
             throw new IPF_ORM_Exception("Couldn't find class " . $name);
@@ -54,32 +53,31 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable
         $this->_options['name'] = $name;
         $this->_parser = new IPF_ORM_Relation_Parser($this);
 
-        if ($initDefinition) {
-            $this->record = $this->initDefinition();
+        $this->initParents($name);
 
-            $this->initIdentifier();
+        // create database table
+        $record = new $name($this);
+        $record->setTableDefinition();
 
-            $this->record->setUp();
-        } else {
-            if ( ! isset($this->_options['tableName'])) {
-                $this->setTableName(IPF_ORM_Inflector::tableize($this->_options['name']));
-            }
+        $this->columnCount = count($this->_columns);
+
+        if (!isset($this->_options['tableName'])) {
+            $this->setTableName(IPF_ORM_Inflector::tableize($class->getName()));
         }
+
+        $this->initIdentifier();
+
+        $record->setUp();
+
         $this->_filters[]  = new IPF_ORM_Record_Filter_Standard();
         $this->_repository = new IPF_ORM_Table_Repository($this);
     }
 
-    public function initDefinition()
+    private function initParents($name)
     {
-        $name = $this->_options['name'];
-        $record = new $name($this);
-
         $names = array();
 
         $class = $name;
-
-        // get parent classes
-
         do {
             if ($class === 'IPF_ORM_Record')
                 break;
@@ -96,27 +94,6 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable
         // save parents
         array_pop($names);
         $this->_options['parents'] = $names;
-
-        // create database table
-        if (method_exists($record, 'setTableDefinition')) {
-            $record->setTableDefinition();
-            // get the declaring class of setTableDefinition method
-            $method = new ReflectionMethod($this->_options['name'], 'setTableDefinition');
-            $class = $method->getDeclaringClass();
-
-        } else {
-            $class = new ReflectionClass($class);
-        }
-
-        $this->_options['declaringClass'] = $class;
-
-        $this->columnCount = count($this->_columns);
-
-        if ( ! isset($this->_options['tableName'])) {
-            $this->setTableName(IPF_ORM_Inflector::tableize($class->getName()));
-        }
-
-        return $record;
     }
 
     public function initIdentifier()