From c038365e997552ee2461ff8883e42c723a991e62 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sat, 27 Jul 2013 20:57:48 +0300 Subject: [PATCH] refactor attribute and option definitions --- ipf/admin/models/_generated/BaseAdminLog.php | 6 +++--- ipf/auth/models/_generated/BasePermission.php | 6 +++--- ipf/auth/models/_generated/BaseRole.php | 6 +++--- .../models/_generated/BaseRolePermission.php | 6 +++--- ipf/auth/models/_generated/BaseUser.php | 6 +++--- .../models/_generated/BaseUserPermission.php | 6 +++--- ipf/auth/models/_generated/BaseUserRole.php | 6 +++--- ipf/orm/import/builder.php | 5 ++--- ipf/orm/record/abstract.php | 20 ------------------- 9 files changed, 23 insertions(+), 44 deletions(-) diff --git a/ipf/admin/models/_generated/BaseAdminLog.php b/ipf/admin/models/_generated/BaseAdminLog.php index 2dd2a75..264672f 100644 --- a/ipf/admin/models/_generated/BaseAdminLog.php +++ b/ipf/admin/models/_generated/BaseAdminLog.php @@ -23,9 +23,9 @@ abstract class BaseAdminLog extends IPF_ORM_Record $table->addIndex('idx_object_class', array('fields' => 'object_class')); $table->addIndex('idx_created_at', array('fields' => 'created_at')); $table->addIndex('idx_action_flag', array('fields' => 'action_flag')); - $this->option('type', 'INNODB'); - $this->option('collate', 'utf8_unicode_ci'); - $this->option('charset', 'utf8'); + $table->setOption('type', 'INNODB'); + $table->setOption('collate', 'utf8_unicode_ci'); + $table->setOption('charset', 'utf8'); } diff --git a/ipf/auth/models/_generated/BasePermission.php b/ipf/auth/models/_generated/BasePermission.php index cf0e609..832cdbf 100644 --- a/ipf/auth/models/_generated/BasePermission.php +++ b/ipf/auth/models/_generated/BasePermission.php @@ -13,9 +13,9 @@ abstract class BasePermission extends IPF_ORM_Record $table = $this->getTable(); $table->setTableName('auth_permission'); $this->getTable()->setColumn('name', 'string', 255, array('unique' => true, 'type' => 'string', 'length' => '255')); - $this->option('type', 'INNODB'); - $this->option('collate', 'utf8_unicode_ci'); - $this->option('charset', 'utf8'); + $table->setOption('type', 'INNODB'); + $table->setOption('collate', 'utf8_unicode_ci'); + $table->setOption('charset', 'utf8'); } diff --git a/ipf/auth/models/_generated/BaseRole.php b/ipf/auth/models/_generated/BaseRole.php index 45c8e05..79bc9fb 100644 --- a/ipf/auth/models/_generated/BaseRole.php +++ b/ipf/auth/models/_generated/BaseRole.php @@ -13,9 +13,9 @@ abstract class BaseRole extends IPF_ORM_Record $table = $this->getTable(); $table->setTableName('auth_role'); $this->getTable()->setColumn('name', 'string', 255, array('unique' => true, 'type' => 'string', 'notblank' => true, 'length' => '255')); - $this->option('type', 'INNODB'); - $this->option('collate', 'utf8_unicode_ci'); - $this->option('charset', 'utf8'); + $table->setOption('type', 'INNODB'); + $table->setOption('collate', 'utf8_unicode_ci'); + $table->setOption('charset', 'utf8'); } diff --git a/ipf/auth/models/_generated/BaseRolePermission.php b/ipf/auth/models/_generated/BaseRolePermission.php index e20a9ce..67b6eb7 100644 --- a/ipf/auth/models/_generated/BaseRolePermission.php +++ b/ipf/auth/models/_generated/BaseRolePermission.php @@ -14,9 +14,9 @@ abstract class BaseRolePermission extends IPF_ORM_Record $table->setTableName('auth_role_permission'); $this->getTable()->setColumn('role_id', 'integer', null, array('type' => 'integer', 'primary' => true)); $this->getTable()->setColumn('permission_id', 'integer', null, array('type' => 'integer', 'primary' => true)); - $this->option('type', 'INNODB'); - $this->option('collate', 'utf8_unicode_ci'); - $this->option('charset', 'utf8'); + $table->setOption('type', 'INNODB'); + $table->setOption('collate', 'utf8_unicode_ci'); + $table->setOption('charset', 'utf8'); } diff --git a/ipf/auth/models/_generated/BaseUser.php b/ipf/auth/models/_generated/BaseUser.php index aee003b..c11f08c 100644 --- a/ipf/auth/models/_generated/BaseUser.php +++ b/ipf/auth/models/_generated/BaseUser.php @@ -21,9 +21,9 @@ abstract class BaseUser extends IPF_ORM_Record $this->getTable()->setColumn('is_active', 'boolean', null, array('type' => 'boolean', 'notnull' => true, 'default' => false)); $this->getTable()->setColumn('is_superuser', 'boolean', null, array('type' => 'boolean', 'notnull' => true, 'default' => false)); $this->getTable()->setColumn('last_login', 'timestamp', null, array('type' => 'timestamp')); - $this->option('type', 'INNODB'); - $this->option('collate', 'utf8_unicode_ci'); - $this->option('charset', 'utf8'); + $table->setOption('type', 'INNODB'); + $table->setOption('collate', 'utf8_unicode_ci'); + $table->setOption('charset', 'utf8'); } diff --git a/ipf/auth/models/_generated/BaseUserPermission.php b/ipf/auth/models/_generated/BaseUserPermission.php index 0034fbc..827c84a 100644 --- a/ipf/auth/models/_generated/BaseUserPermission.php +++ b/ipf/auth/models/_generated/BaseUserPermission.php @@ -14,9 +14,9 @@ abstract class BaseUserPermission extends IPF_ORM_Record $table->setTableName('auth_user_permission'); $this->getTable()->setColumn('user_id', 'integer', null, array('type' => 'integer', 'primary' => true)); $this->getTable()->setColumn('permission_id', 'integer', null, array('type' => 'integer', 'primary' => true)); - $this->option('type', 'INNODB'); - $this->option('collate', 'utf8_unicode_ci'); - $this->option('charset', 'utf8'); + $table->setOption('type', 'INNODB'); + $table->setOption('collate', 'utf8_unicode_ci'); + $table->setOption('charset', 'utf8'); } diff --git a/ipf/auth/models/_generated/BaseUserRole.php b/ipf/auth/models/_generated/BaseUserRole.php index b49c39c..5905cbb 100644 --- a/ipf/auth/models/_generated/BaseUserRole.php +++ b/ipf/auth/models/_generated/BaseUserRole.php @@ -14,9 +14,9 @@ abstract class BaseUserRole extends IPF_ORM_Record $table->setTableName('auth_user_role'); $this->getTable()->setColumn('user_id', 'integer', null, array('type' => 'integer', 'primary' => true)); $this->getTable()->setColumn('role_id', 'integer', null, array('type' => 'integer', 'primary' => true)); - $this->option('type', 'INNODB'); - $this->option('collate', 'utf8_unicode_ci'); - $this->option('charset', 'utf8'); + $table->setOption('type', 'INNODB'); + $table->setOption('collate', 'utf8_unicode_ci'); + $table->setOption('charset', 'utf8'); } diff --git a/ipf/orm/import/builder.php b/ipf/orm/import/builder.php index bdb1728..3be0494 100644 --- a/ipf/orm/import/builder.php +++ b/ipf/orm/import/builder.php @@ -293,7 +293,7 @@ class IPF_ORM_Import_Builder $values = substr($values, 0, strlen($values) - 3); } - $build .= " \$this->setAttribute(IPF_ORM::ATTR_" . strtoupper($key) . ", " . $values . ");" . PHP_EOL; + $build .= " \$table->setAttribute(IPF_ORM::ATTR_" . strtoupper($key) . ", " . $values . ");" . PHP_EOL; } return $build; @@ -303,9 +303,8 @@ class IPF_ORM_Import_Builder { $build = ''; foreach ($options as $name => $value) { - $build .= " \$this->option('$name', " . self::varExport($value) . ");" . PHP_EOL; + $build .= " \$table->setOption('$name', " . self::varExport($value) . ");" . PHP_EOL; } - return $build; } diff --git a/ipf/orm/record/abstract.php b/ipf/orm/record/abstract.php index 29058f2..1a1cbf7 100644 --- a/ipf/orm/record/abstract.php +++ b/ipf/orm/record/abstract.php @@ -17,11 +17,6 @@ abstract class IPF_ORM_Record_Abstract extends IPF_ORM_Access return $this->_table; } - public function setAttribute($attr, $value) - { - $this->_table->setAttribute($attr, $value); - } - public function setInheritanceMap($map) { $this->_table->setOption('inheritanceMap', $map); @@ -51,21 +46,6 @@ abstract class IPF_ORM_Record_Abstract extends IPF_ORM_Access } } - public function option($name, $value = null) - { - if ($value === null) { - if (is_array($name)) { - foreach ($name as $k => $v) { - $this->_table->setOption($k, $v); - } - } else { - return $this->_table->getOption($name); - } - } else { - $this->_table->setOption($name, $value); - } - } - public function ownsOne() { $this->_table->bind(func_get_args(), IPF_ORM_Relation::ONE_COMPOSITE); -- 2.49.0