]> git.andy128k.dev Git - ipf.git/commitdiff
load models refactor DirectoryIterator
authorDmitryPuchkov <devnull@localhost>
Wed, 3 Sep 2008 15:41:34 +0000 (18:41 +0300)
committerDmitryPuchkov <devnull@localhost>
Wed, 3 Sep 2008 15:41:34 +0000 (18:41 +0300)
ipf.php
ipf/admin/models/_generated/BaseAdminLog.php
ipf/auth/models/_generated/BasePermission.php
ipf/auth/models/_generated/BaseRole.php
ipf/auth/models/_generated/BaseRolePermission.php
ipf/auth/models/_generated/BaseUser.php
ipf/auth/models/_generated/BaseUserPermission.php
ipf/auth/models/_generated/BaseUserRole.php
ipf/orm.php
ipf/session/models/_generated/BaseSession.php

diff --git a/ipf.php b/ipf.php
index 3ef90c4c876e2a1cc0f5aae66bf40654d7fd9cbe..a1bdebf88201433e9ef9a56d532a155005a9bcc9 100644 (file)
--- a/ipf.php
+++ b/ipf.php
@@ -9,6 +9,11 @@ function __autoload( $class_name ){
             $s .= '/';                                                  
         $s .= strtolower( $folder );                                            
     }
+    if ($s=='basesession'){
+       //print_r( debug_backtrace(false));
+       debug_print_backtrace();
+       die ('zzz');
+    }
     require_once($s.'.php');
 }
 
index 930e5eb311643c9d636a349d91fe0d37114684f0..31b037eab592de13c448670d207eb598d0bf6114 100644 (file)
@@ -1,34 +1,34 @@
-<?php
-
-/**
- * This class has been auto-generated by the IPF_ORM Framework
- */
-abstract class BaseAdminLog extends IPF_ORM_Record
-{
-  public function setTableDefinition()
-  {
-    $this->setTableName('admin_log');
-    $this->hasColumn('username', 'string', 32, array('type' => 'string', 'length' => '32'));
-    $this->hasColumn('user_id', 'integer', null, array('type' => 'integer'));
-    $this->hasColumn('object_id', 'integer', null, array('type' => 'integer'));
-    $this->hasColumn('object_class', 'string', 200, array('type' => 'string', 'length' => '200'));
-    $this->hasColumn('object_repr', 'string', 200, array('type' => 'string', 'length' => '200'));
-    $this->hasColumn('action_flag', 'integer', null, array('type' => 'integer'));
-    $this->hasColumn('change_message', 'string', 200, array('type' => 'string', 'length' => '200'));
-
-
-    $this->index('idx_object_id', array('fields' => 'object_id'));
-    $this->index('idx_object_class', array('fields' => 'object_class'));
-    $this->index('idx_created_at', array('fields' => 'created_at'));
-    $this->index('idx_action_flag', array('fields' => 'action_flag'));
-    $this->option('type', 'INNODB');
-    $this->option('collate', 'utf8_unicode_ci');
-    $this->option('charset', 'utf8');
-  }
-
-  public function setUp()
-  {
-    $timestampable0 = new IPF_ORM_Template_Timestampable(array('updated' => array('disabled' => true)));
-    $this->actAs($timestampable0);
-  }
+<?php\r
+\r
+/**\r
+ * This class has been auto-generated by the IPF_ORM Framework\r
+ */\r
+abstract class BaseAdminLog extends IPF_ORM_Record\r
+{\r
+  public function setTableDefinition()\r
+  {\r
+    $this->setTableName('admin_log');\r
+    $this->hasColumn('username', 'string', 32, array('type' => 'string', 'length' => '32'));\r
+    $this->hasColumn('user_id', 'integer', null, array('type' => 'integer'));\r
+    $this->hasColumn('object_id', 'integer', null, array('type' => 'integer'));\r
+    $this->hasColumn('object_class', 'string', 200, array('type' => 'string', 'length' => '200'));\r
+    $this->hasColumn('object_repr', 'string', 200, array('type' => 'string', 'length' => '200'));\r
+    $this->hasColumn('action_flag', 'integer', null, array('type' => 'integer'));\r
+    $this->hasColumn('change_message', 'string', 200, array('type' => 'string', 'length' => '200'));\r
+\r
+\r
+    $this->index('idx_object_id', array('fields' => 'object_id'));\r
+    $this->index('idx_object_class', array('fields' => 'object_class'));\r
+    $this->index('idx_created_at', array('fields' => 'created_at'));\r
+    $this->index('idx_action_flag', array('fields' => 'action_flag'));\r
+    $this->option('type', 'INNODB');\r
+    $this->option('collate', 'utf8_unicode_ci');\r
+    $this->option('charset', 'utf8');\r
+  }\r
+\r
+  public function setUp()\r
+  {\r
+    $timestampable0 = new IPF_ORM_Template_Timestampable(array('updated' => array('disabled' => true)));\r
+    $this->actAs($timestampable0);\r
+  }\r
 }
\ No newline at end of file
index 4be989166a207f7637725be1ec0f60efc7f58064..1fabde24cbc7b5f76b07e7e91bec66555452ade5 100644 (file)
@@ -1,30 +1,30 @@
-<?php
-
-/**
- * This class has been auto-generated by the IPF_ORM Framework
- */
-abstract class BasePermission extends IPF_ORM_Record
-{
-  public function setTableDefinition()
-  {
-    $this->setTableName('auth_permission');
-    $this->hasColumn('name', 'string', 255, array('unique' => true, 'type' => 'string', 'length' => '255'));
-
-    $this->option('type', 'INNODB');
-    $this->option('collate', 'utf8_unicode_ci');
-    $this->option('charset', 'utf8');
-  }
-
-  public function setUp()
-  {
-    $this->hasMany('User as Users', array('refClass' => 'UserPermission',
-                                          'local' => 'permission_id',
-                                          'foreign' => 'user_id'));
-
-    $this->hasMany('RolePermission', array('local' => 'id',
-                                           'foreign' => 'permission_id'));
-
-    $this->hasMany('UserPermission', array('local' => 'id',
-                                           'foreign' => 'permission_id'));
-  }
+<?php\r
+\r
+/**\r
+ * This class has been auto-generated by the IPF_ORM Framework\r
+ */\r
+abstract class BasePermission extends IPF_ORM_Record\r
+{\r
+  public function setTableDefinition()\r
+  {\r
+    $this->setTableName('auth_permission');\r
+    $this->hasColumn('name', 'string', 255, array('unique' => true, 'type' => 'string', 'length' => '255'));\r
+\r
+    $this->option('type', 'INNODB');\r
+    $this->option('collate', 'utf8_unicode_ci');\r
+    $this->option('charset', 'utf8');\r
+  }\r
+\r
+  public function setUp()\r
+  {\r
+    $this->hasMany('User as Users', array('refClass' => 'UserPermission',\r
+                                          'local' => 'permission_id',\r
+                                          'foreign' => 'user_id'));\r
+\r
+    $this->hasMany('RolePermission', array('local' => 'id',\r
+                                           'foreign' => 'permission_id'));\r
+\r
+    $this->hasMany('UserPermission', array('local' => 'id',\r
+                                           'foreign' => 'permission_id'));\r
+  }\r
 }
\ No newline at end of file
index 6486330b9935c3d9eb8579106c2cb1cef952c796..d48cde086fb6cc1cc948c4769025575d117a9137 100644 (file)
@@ -1,30 +1,30 @@
-<?php
-
-/**
- * This class has been auto-generated by the IPF_ORM Framework
- */
-abstract class BaseRole extends IPF_ORM_Record
-{
-  public function setTableDefinition()
-  {
-    $this->setTableName('auth_role');
-    $this->hasColumn('name', 'string', 255, array('unique' => true, 'type' => 'string', 'length' => '255'));
-
-    $this->option('type', 'INNODB');
-    $this->option('collate', 'utf8_unicode_ci');
-    $this->option('charset', 'utf8');
-  }
-
-  public function setUp()
-  {
-    $this->hasMany('User as Users', array('refClass' => 'UserRole',
-                                          'local' => 'role_id',
-                                          'foreign' => 'user_id'));
-
-    $this->hasMany('RolePermission', array('local' => 'id',
-                                           'foreign' => 'role_id'));
-
-    $this->hasMany('UserRole', array('local' => 'id',
-                                     'foreign' => 'role_id'));
-  }
+<?php\r
+\r
+/**\r
+ * This class has been auto-generated by the IPF_ORM Framework\r
+ */\r
+abstract class BaseRole extends IPF_ORM_Record\r
+{\r
+  public function setTableDefinition()\r
+  {\r
+    $this->setTableName('auth_role');\r
+    $this->hasColumn('name', 'string', 255, array('unique' => true, 'type' => 'string', 'length' => '255'));\r
+\r
+    $this->option('type', 'INNODB');\r
+    $this->option('collate', 'utf8_unicode_ci');\r
+    $this->option('charset', 'utf8');\r
+  }\r
+\r
+  public function setUp()\r
+  {\r
+    $this->hasMany('User as Users', array('refClass' => 'UserRole',\r
+                                          'local' => 'role_id',\r
+                                          'foreign' => 'user_id'));\r
+\r
+    $this->hasMany('RolePermission', array('local' => 'id',\r
+                                           'foreign' => 'role_id'));\r
+\r
+    $this->hasMany('UserRole', array('local' => 'id',\r
+                                     'foreign' => 'role_id'));\r
+  }\r
 }
\ No newline at end of file
index 807bb5b41758bd40dc18d6ec70baff88ae714aa1..5f49ef43c90145218b5ee2160bb2e56dfce6c8df 100644 (file)
@@ -1,27 +1,27 @@
-<?php
-
-/**
- * This class has been auto-generated by the IPF_ORM Framework
- */
-abstract class BaseRolePermission extends IPF_ORM_Record
-{
-  public function setTableDefinition()
-  {
-    $this->setTableName('auth_role_permission');
-    $this->hasColumn('role_id', 'integer', null, array('type' => 'integer', 'primary' => true));
-    $this->hasColumn('permission_id', 'integer', null, array('type' => 'integer', 'primary' => true));
-
-    $this->option('type', 'INNODB');
-    $this->option('collate', 'utf8_unicode_ci');
-    $this->option('charset', 'utf8');
-  }
-
-  public function setUp()
-  {
-    $this->hasOne('Role', array('local' => 'role_id',
-                                'foreign' => 'id'));
-
-    $this->hasOne('Permission', array('local' => 'permission_id',
-                                      'foreign' => 'id'));
-  }
+<?php\r
+\r
+/**\r
+ * This class has been auto-generated by the IPF_ORM Framework\r
+ */\r
+abstract class BaseRolePermission extends IPF_ORM_Record\r
+{\r
+  public function setTableDefinition()\r
+  {\r
+    $this->setTableName('auth_role_permission');\r
+    $this->hasColumn('role_id', 'integer', null, array('type' => 'integer', 'primary' => true));\r
+    $this->hasColumn('permission_id', 'integer', null, array('type' => 'integer', 'primary' => true));\r
+\r
+    $this->option('type', 'INNODB');\r
+    $this->option('collate', 'utf8_unicode_ci');\r
+    $this->option('charset', 'utf8');\r
+  }\r
+\r
+  public function setUp()\r
+  {\r
+    $this->hasOne('Role', array('local' => 'role_id',\r
+                                'foreign' => 'id'));\r
+\r
+    $this->hasOne('Permission', array('local' => 'permission_id',\r
+                                      'foreign' => 'id'));\r
+  }\r
 }
\ No newline at end of file
index 85e5e88255959c4b074f4c52b2da8bc9b3bc5b9a..7f4f7721dc99107cffb103f60c5e4d0bb68b59a4 100644 (file)
@@ -1,45 +1,45 @@
-<?php
-
-/**
- * This class has been auto-generated by the IPF_ORM Framework
- */
-abstract class BaseUser extends IPF_ORM_Record
-{
-  public function setTableDefinition()
-  {
-    $this->setTableName('auth_user');
-    $this->hasColumn('username', 'string', 32, array('type' => 'string', 'notblank' => true, 'notnull' => true, 'unique' => true, 'length' => '32'));
-    $this->hasColumn('password', 'string', 128, array('type' => 'string', 'notblank' => true, 'notnull' => true, 'length' => '128'));
-    $this->hasColumn('first_name', 'string', 32, array('type' => 'string', 'length' => '32'));
-    $this->hasColumn('last_name', 'string', 32, array('type' => 'string', 'length' => '32'));
-    $this->hasColumn('email', 'string', 200, array('type' => 'string', 'email' => true, 'notnull' => true, 'notblank' => true, 'unique' => true, 'length' => '200'));
-    $this->hasColumn('is_staff', 'boolean', null, array('type' => 'boolean', 'notnull' => true, 'default' => false));
-    $this->hasColumn('is_active', 'boolean', null, array('type' => 'boolean', 'notnull' => true, 'default' => false));
-    $this->hasColumn('is_superuser', 'boolean', null, array('type' => 'boolean', 'notnull' => true, 'default' => false));
-    $this->hasColumn('last_login', 'timestamp', null, array('type' => 'timestamp'));
-
-    $this->option('type', 'INNODB');
-    $this->option('collate', 'utf8_unicode_ci');
-    $this->option('charset', 'utf8');
-  }
-
-  public function setUp()
-  {
-    $this->hasMany('Role as Roles', array('refClass' => 'UserRole',
-                                          'local' => 'user_id',
-                                          'foreign' => 'role_id'));
-
-    $this->hasMany('Permission as Permissions', array('refClass' => 'UserPermission',
-                                                      'local' => 'user_id',
-                                                      'foreign' => 'permission_id'));
-
-    $this->hasMany('UserRole', array('local' => 'id',
-                                     'foreign' => 'user_id'));
-
-    $this->hasMany('UserPermission', array('local' => 'id',
-                                           'foreign' => 'user_id'));
-
-    $timestampable0 = new IPF_ORM_Template_Timestampable();
-    $this->actAs($timestampable0);
-  }
+<?php\r
+\r
+/**\r
+ * This class has been auto-generated by the IPF_ORM Framework\r
+ */\r
+abstract class BaseUser extends IPF_ORM_Record\r
+{\r
+  public function setTableDefinition()\r
+  {\r
+    $this->setTableName('auth_user');\r
+    $this->hasColumn('username', 'string', 32, array('type' => 'string', 'notblank' => true, 'notnull' => true, 'unique' => true, 'length' => '32'));\r
+    $this->hasColumn('password', 'string', 128, array('type' => 'string', 'notblank' => true, 'notnull' => true, 'length' => '128'));\r
+    $this->hasColumn('first_name', 'string', 32, array('type' => 'string', 'length' => '32'));\r
+    $this->hasColumn('last_name', 'string', 32, array('type' => 'string', 'length' => '32'));\r
+    $this->hasColumn('email', 'string', 200, array('type' => 'string', 'email' => true, 'notnull' => true, 'notblank' => true, 'unique' => true, 'length' => '200'));\r
+    $this->hasColumn('is_staff', 'boolean', null, array('type' => 'boolean', 'notnull' => true, 'default' => false));\r
+    $this->hasColumn('is_active', 'boolean', null, array('type' => 'boolean', 'notnull' => true, 'default' => false));\r
+    $this->hasColumn('is_superuser', 'boolean', null, array('type' => 'boolean', 'notnull' => true, 'default' => false));\r
+    $this->hasColumn('last_login', 'timestamp', null, array('type' => 'timestamp'));\r
+\r
+    $this->option('type', 'INNODB');\r
+    $this->option('collate', 'utf8_unicode_ci');\r
+    $this->option('charset', 'utf8');\r
+  }\r
+\r
+  public function setUp()\r
+  {\r
+    $this->hasMany('Role as Roles', array('refClass' => 'UserRole',\r
+                                          'local' => 'user_id',\r
+                                          'foreign' => 'role_id'));\r
+\r
+    $this->hasMany('Permission as Permissions', array('refClass' => 'UserPermission',\r
+                                                      'local' => 'user_id',\r
+                                                      'foreign' => 'permission_id'));\r
+\r
+    $this->hasMany('UserRole', array('local' => 'id',\r
+                                     'foreign' => 'user_id'));\r
+\r
+    $this->hasMany('UserPermission', array('local' => 'id',\r
+                                           'foreign' => 'user_id'));\r
+\r
+    $timestampable0 = new IPF_ORM_Template_Timestampable();\r
+    $this->actAs($timestampable0);\r
+  }\r
 }
\ No newline at end of file
index 988247a0b3eb7c62052d52ddad4ad41a4f097ea0..f8cfbd762c87926d610ce164169c90739ee5f4e1 100644 (file)
@@ -1,27 +1,27 @@
-<?php
-
-/**
- * This class has been auto-generated by the IPF_ORM Framework
- */
-abstract class BaseUserPermission extends IPF_ORM_Record
-{
-  public function setTableDefinition()
-  {
-    $this->setTableName('auth_user_permission');
-    $this->hasColumn('user_id', 'integer', null, array('type' => 'integer', 'primary' => true));
-    $this->hasColumn('permission_id', 'integer', null, array('type' => 'integer', 'primary' => true));
-
-    $this->option('type', 'INNODB');
-    $this->option('collate', 'utf8_unicode_ci');
-    $this->option('charset', 'utf8');
-  }
-
-  public function setUp()
-  {
-    $this->hasOne('User', array('local' => 'user_id',
-                                'foreign' => 'id'));
-
-    $this->hasOne('Permission', array('local' => 'permission_id',
-                                      'foreign' => 'id'));
-  }
+<?php\r
+\r
+/**\r
+ * This class has been auto-generated by the IPF_ORM Framework\r
+ */\r
+abstract class BaseUserPermission extends IPF_ORM_Record\r
+{\r
+  public function setTableDefinition()\r
+  {\r
+    $this->setTableName('auth_user_permission');\r
+    $this->hasColumn('user_id', 'integer', null, array('type' => 'integer', 'primary' => true));\r
+    $this->hasColumn('permission_id', 'integer', null, array('type' => 'integer', 'primary' => true));\r
+\r
+    $this->option('type', 'INNODB');\r
+    $this->option('collate', 'utf8_unicode_ci');\r
+    $this->option('charset', 'utf8');\r
+  }\r
+\r
+  public function setUp()\r
+  {\r
+    $this->hasOne('User', array('local' => 'user_id',\r
+                                'foreign' => 'id'));\r
+\r
+    $this->hasOne('Permission', array('local' => 'permission_id',\r
+                                      'foreign' => 'id'));\r
+  }\r
 }
\ No newline at end of file
index 363ff0113f56b57cc1cde250038fac95e7c606d2..ec5b476b8190c16ce4a45a3bb6df9deab2e5735a 100644 (file)
@@ -1,27 +1,27 @@
-<?php
-
-/**
- * This class has been auto-generated by the IPF_ORM Framework
- */
-abstract class BaseUserRole extends IPF_ORM_Record
-{
-  public function setTableDefinition()
-  {
-    $this->setTableName('auth_user_role');
-    $this->hasColumn('user_id', 'integer', null, array('type' => 'integer', 'primary' => true));
-    $this->hasColumn('role_id', 'integer', null, array('type' => 'integer', 'primary' => true));
-
-    $this->option('type', 'INNODB');
-    $this->option('collate', 'utf8_unicode_ci');
-    $this->option('charset', 'utf8');
-  }
-
-  public function setUp()
-  {
-    $this->hasOne('User', array('local' => 'user_id',
-                                'foreign' => 'id'));
-
-    $this->hasOne('Role', array('local' => 'role_id',
-                                'foreign' => 'id'));
-  }
+<?php\r
+\r
+/**\r
+ * This class has been auto-generated by the IPF_ORM Framework\r
+ */\r
+abstract class BaseUserRole extends IPF_ORM_Record\r
+{\r
+  public function setTableDefinition()\r
+  {\r
+    $this->setTableName('auth_user_role');\r
+    $this->hasColumn('user_id', 'integer', null, array('type' => 'integer', 'primary' => true));\r
+    $this->hasColumn('role_id', 'integer', null, array('type' => 'integer', 'primary' => true));\r
+\r
+    $this->option('type', 'INNODB');\r
+    $this->option('collate', 'utf8_unicode_ci');\r
+    $this->option('charset', 'utf8');\r
+  }\r
+\r
+  public function setUp()\r
+  {\r
+    $this->hasOne('User', array('local' => 'user_id',\r
+                                'foreign' => 'id'));\r
+\r
+    $this->hasOne('Role', array('local' => 'role_id',\r
+                                'foreign' => 'id'));\r
+  }\r
 }
\ No newline at end of file
index f93028221db1530fe68ce4056aa5fd2c67c0296e..7a11103e4d08b475a5ff887c1b9b2fc237ba2912 100644 (file)
@@ -242,43 +242,22 @@ final class IPF_ORM {
 
     public static function loadModels($directory, $modelLoading = null)
     {
-        $manager = IPF_ORM_Manager::getInstance();
-        
-        $modelLoading = $modelLoading === null ? $manager->getAttribute(IPF_ORM::ATTR_MODEL_LOADING):$modelLoading;
         $loadedModels = array();
-        if ($directory !== null) {
-            foreach ((array) $directory as $dir) {
-                if ( ! is_dir($dir)) {
-                    throw new IPF_ORM_Exception('You must pass a valid path to a directory containing IPF_ORM models');
-                }
-                $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY);
-                foreach ($it as $file) {
-                    $e = explode('.', $file->getFileName());
-                    if (end($e) === 'php' && strpos($file->getFileName(), '.inc') === false) {
-                        $className = $e[0];
-                        if ($modelLoading == IPF_ORM::MODEL_LOADING_CONSERVATIVE) {
-                            self::loadModel($className, $file->getPathName());
-                            $loadedModels[$className] = $className;
-                        } else {
-                            //$declaredBefore = get_declared_classes();
-                            require_once($file->getPathName());
-                            $loadedModels[$className] = $className; // !!!
-                            /*
-                            //$declaredAfter = get_declared_classes();
-                            //$foundClasses = array_slice($declaredAfter, count($declaredBefore) - 1);
-                            if ($foundClasses) {
-                                foreach ($foundClasses as $className) {
-                                    if (self::isValidModelClass($className)) {
-                                        $loadedModels[$className] = $className;
-
-                                        self::loadModel($className, $file->getPathName());
-                                    }
-                                }
-                            }
-                            */
-                        }
-                    }
-                }
+        $it = new DirectoryIterator($directory.DIRECTORY_SEPARATOR.'_generated');
+        foreach ($it as $file) {
+            $e = explode('.', $file->getFileName());
+            if (end($e) === 'php') {
+               $className = $e[0];
+               require_once($file->getPathName());
+            }
+        }
+        $it = new DirectoryIterator($directory);
+        foreach ($it as $file) {
+            $e = explode('.', $file->getFileName());
+            if (end($e) === 'php') {
+               $className = $e[0];
+               require_once($file->getPathName());
+               $loadedModels[$className] = $className;
             }
         }
         return $loadedModels;
index b126310ad95b67c03a8cfdd6c689a5e92b3fdb74..4408de9fce9b884e77de6d10139688bb2cb1a3d5 100644 (file)
@@ -1,16 +1,16 @@
-<?php
-
-/**
- * This class has been auto-generated by the IPF_ORM Framework
- */
-abstract class BaseSession extends IPF_ORM_Record
-{
-  public function setTableDefinition()
-  {
-    $this->setTableName('session');
-    $this->hasColumn('session_key', 'string', 40, array('primary' => true, 'type' => 'string', 'length' => '40'));
-    $this->hasColumn('session_data', 'string', null, array('type' => 'string'));
-    $this->hasColumn('expire_data', 'timestamp', null, array('type' => 'timestamp'));
-  }
-
+<?php\r
+\r
+/**\r
+ * This class has been auto-generated by the IPF_ORM Framework\r
+ */\r
+abstract class BaseSession extends IPF_ORM_Record\r
+{\r
+  public function setTableDefinition()\r
+  {\r
+    $this->setTableName('session');\r
+    $this->hasColumn('session_key', 'string', 40, array('primary' => true, 'type' => 'string', 'length' => '40'));\r
+    $this->hasColumn('session_data', 'string', null, array('type' => 'string'));\r
+    $this->hasColumn('expire_data', 'timestamp', null, array('type' => 'timestamp'));\r
+  }\r
+\r
 }
\ No newline at end of file