From 27805a161ff3847d6376328e25279e5e2e0b7d13 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sat, 27 Jul 2013 23:55:36 +0300 Subject: [PATCH] make setUp a static method --- ipf/admin/models/_generated/BaseAdminLog.php | 3 +-- ipf/auth/models/_generated/BasePermission.php | 3 +-- ipf/auth/models/_generated/BaseRole.php | 3 +-- ipf/auth/models/_generated/BaseRolePermission.php | 3 +-- ipf/auth/models/_generated/BaseUser.php | 3 +-- ipf/auth/models/_generated/BaseUserPermission.php | 3 +-- ipf/auth/models/_generated/BaseUserRole.php | 3 +-- ipf/orm/import/builder.php | 7 +++---- ipf/orm/record.php | 1 - ipf/orm/record/abstract.php | 2 +- ipf/orm/table.php | 3 +-- 11 files changed, 12 insertions(+), 22 deletions(-) diff --git a/ipf/admin/models/_generated/BaseAdminLog.php b/ipf/admin/models/_generated/BaseAdminLog.php index 9f55ad4..a26051e 100644 --- a/ipf/admin/models/_generated/BaseAdminLog.php +++ b/ipf/admin/models/_generated/BaseAdminLog.php @@ -28,9 +28,8 @@ abstract class BaseAdminLog extends IPF_ORM_Record } - public function setUp() + public static function setUp(IPF_ORM_Table $table) { - $table = $this->getTable(); $table->addTemplate(new IPF_ORM_Template_Timestampable(array('updated' => array('disabled' => true)))); } diff --git a/ipf/auth/models/_generated/BasePermission.php b/ipf/auth/models/_generated/BasePermission.php index 190b33e..62ab8c4 100644 --- a/ipf/auth/models/_generated/BasePermission.php +++ b/ipf/auth/models/_generated/BasePermission.php @@ -18,9 +18,8 @@ abstract class BasePermission extends IPF_ORM_Record } - public function setUp() + public static function setUp(IPF_ORM_Table $table) { - $table = $this->getTable(); $table->hasMany('User', 'Users', array('refClass' => 'UserPermission', 'local' => 'permission_id', 'foreign' => 'user_id')); $table->hasMany('Role', 'Roles', array('refClass' => 'RolePermission', 'local' => 'permission_id', 'foreign' => 'role_id')); $table->hasMany('RolePermission', '', array('local' => 'id', 'foreign' => 'permission_id')); diff --git a/ipf/auth/models/_generated/BaseRole.php b/ipf/auth/models/_generated/BaseRole.php index 0e72b24..0099fab 100644 --- a/ipf/auth/models/_generated/BaseRole.php +++ b/ipf/auth/models/_generated/BaseRole.php @@ -18,9 +18,8 @@ abstract class BaseRole extends IPF_ORM_Record } - public function setUp() + public static function setUp(IPF_ORM_Table $table) { - $table = $this->getTable(); $table->hasMany('Permission', 'Permissions', array('refClass' => 'RolePermission', 'local' => 'role_id', 'foreign' => 'permission_id')); $table->hasMany('User', 'Users', array('refClass' => 'UserRole', 'local' => 'role_id', 'foreign' => 'user_id')); $table->hasMany('RolePermission', '', array('local' => 'id', 'foreign' => 'role_id')); diff --git a/ipf/auth/models/_generated/BaseRolePermission.php b/ipf/auth/models/_generated/BaseRolePermission.php index e01c1de..b4da1a4 100644 --- a/ipf/auth/models/_generated/BaseRolePermission.php +++ b/ipf/auth/models/_generated/BaseRolePermission.php @@ -19,9 +19,8 @@ abstract class BaseRolePermission extends IPF_ORM_Record } - public function setUp() + public static function setUp(IPF_ORM_Table $table) { - $table = $this->getTable(); $table->hasOne('Role', '', array('local' => 'role_id', 'foreign' => 'id', 'onDelete' => 'CASCADE')); $table->hasOne('Permission', '', array('local' => 'permission_id', 'foreign' => 'id', 'onDelete' => 'CASCADE')); } diff --git a/ipf/auth/models/_generated/BaseUser.php b/ipf/auth/models/_generated/BaseUser.php index 98c8483..0411e71 100644 --- a/ipf/auth/models/_generated/BaseUser.php +++ b/ipf/auth/models/_generated/BaseUser.php @@ -26,9 +26,8 @@ abstract class BaseUser extends IPF_ORM_Record } - public function setUp() + public static function setUp(IPF_ORM_Table $table) { - $table = $this->getTable(); $table->hasMany('Role', 'Roles', array('refClass' => 'UserRole', 'local' => 'user_id', 'foreign' => 'role_id')); $table->hasMany('Permission', 'Permissions', array('refClass' => 'UserPermission', 'local' => 'user_id', 'foreign' => 'permission_id')); $table->hasMany('UserRole', '', array('local' => 'id', 'foreign' => 'user_id')); diff --git a/ipf/auth/models/_generated/BaseUserPermission.php b/ipf/auth/models/_generated/BaseUserPermission.php index c45e3a6..198ac96 100644 --- a/ipf/auth/models/_generated/BaseUserPermission.php +++ b/ipf/auth/models/_generated/BaseUserPermission.php @@ -19,9 +19,8 @@ abstract class BaseUserPermission extends IPF_ORM_Record } - public function setUp() + public static function setUp(IPF_ORM_Table $table) { - $table = $this->getTable(); $table->hasOne('User', '', array('local' => 'user_id', 'foreign' => 'id', 'onDelete' => 'CASCADE')); $table->hasOne('Permission', '', array('local' => 'permission_id', 'foreign' => 'id', 'onDelete' => 'CASCADE')); } diff --git a/ipf/auth/models/_generated/BaseUserRole.php b/ipf/auth/models/_generated/BaseUserRole.php index c9d50e0..9297d16 100644 --- a/ipf/auth/models/_generated/BaseUserRole.php +++ b/ipf/auth/models/_generated/BaseUserRole.php @@ -19,9 +19,8 @@ abstract class BaseUserRole extends IPF_ORM_Record } - public function setUp() + public static function setUp(IPF_ORM_Table $table) { - $table = $this->getTable(); $table->hasOne('User', '', array('local' => 'user_id', 'foreign' => 'id', 'onDelete' => 'CASCADE')); $table->hasOne('Role', '', array('local' => 'role_id', 'foreign' => 'id', 'onDelete' => 'CASCADE')); } diff --git a/ipf/orm/import/builder.php b/ipf/orm/import/builder.php index 6e3bc0f..362de0b 100644 --- a/ipf/orm/import/builder.php +++ b/ipf/orm/import/builder.php @@ -135,15 +135,14 @@ class IPF_ORM_Import_Builder // then we need call the parent::setUp() before the body of the function // Class table inheritance is the only one we shouldn't call parent::setUp() for if (count($ret) && isset($definition['inheritance']['type']) && $definition['inheritance']['type'] != 'class_table') { - array_unshift($ret, ' parent::setUp();'); + array_unshift($ret, ' parent::setUp($table);'); } // If we have some code for the function then lets define it and return it if (count($ret)) { array_unshift($ret, - ' public function setUp()', - ' {', - ' $table = $this->getTable();' + ' public static function setUp(IPF_ORM_Table $table)', + ' {' ); $ret[] = ' }'; } diff --git a/ipf/orm/record.php b/ipf/orm/record.php index a89718d..29b0e0d 100644 --- a/ipf/orm/record.php +++ b/ipf/orm/record.php @@ -82,7 +82,6 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab return self::$_index; } - public function setUp(){} public function construct(){} public function getOid() diff --git a/ipf/orm/record/abstract.php b/ipf/orm/record/abstract.php index 3276a67..6365187 100644 --- a/ipf/orm/record/abstract.php +++ b/ipf/orm/record/abstract.php @@ -8,7 +8,7 @@ abstract class IPF_ORM_Record_Abstract extends IPF_ORM_Access { } - public function setUp() + public static function setUp(IPF_ORM_Table $table) { } diff --git a/ipf/orm/table.php b/ipf/orm/table.php index aec975a..af035c0 100644 --- a/ipf/orm/table.php +++ b/ipf/orm/table.php @@ -65,8 +65,7 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable $this->initIdentifier(); - $record = new $name($this); - $record->setUp(); + $name::setUp($this); $this->_filters[] = new IPF_ORM_Record_Filter_Standard(); $this->_repository = new IPF_ORM_Table_Repository($this); -- 2.49.0