From 92a7791384051eccc836f2691585c38f51ae207c Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Mon, 1 Jul 2013 00:28:03 +0300 Subject: [PATCH] 'exclude' and 'foreignExclude' model options. exclude ord in Orderable template --- ipf/orm/import/schema.php | 5 ++++- ipf/orm/relation.php | 1 + ipf/orm/template/orderable.php | 2 +- ipf/orm/validator/exclude.php | 10 ++++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 ipf/orm/validator/exclude.php diff --git a/ipf/orm/import/schema.php b/ipf/orm/import/schema.php index a4c67c2..9a461f0 100644 --- a/ipf/orm/import/schema.php +++ b/ipf/orm/import/schema.php @@ -48,7 +48,8 @@ class IPF_ORM_Import_Schema 'sequence', 'protected', 'zerofill', - 'owner'), + 'owner', + 'exclude'), 'relation' => array('key', 'class', @@ -60,6 +61,7 @@ class IPF_ORM_Import_Schema 'foreignClass', 'foreignAlias', 'foreignType', + 'foreignExclude', 'autoComplete', 'onDelete', 'onUpdate', @@ -469,6 +471,7 @@ class IPF_ORM_Import_Schema $newRelation['local'] = $relation['foreign']; $newRelation['class'] = isset($relation['foreignClass']) ? $relation['foreignClass']:$className; $newRelation['alias'] = isset($relation['foreignAlias']) ? $relation['foreignAlias']:$className; + $newRelation['exclude'] = isset($relation['foreignExclude']) ? $relation['foreignExclude']:$className; // this is so that we know that this relation was autogenerated and // that we do not need to include it if it is explicitly declared in the schema by the users. diff --git a/ipf/orm/relation.php b/ipf/orm/relation.php index 7427197..8c43bcc 100644 --- a/ipf/orm/relation.php +++ b/ipf/orm/relation.php @@ -27,6 +27,7 @@ abstract class IPF_ORM_Relation implements ArrayAccess 'equal' => false, 'cascade' => array(), // application-level cascades 'owningSide' => false, // whether this is the owning side + 'exclude' => false, ); public function __construct(array $definition) diff --git a/ipf/orm/template/orderable.php b/ipf/orm/template/orderable.php index 1935e70..0d26546 100644 --- a/ipf/orm/template/orderable.php +++ b/ipf/orm/template/orderable.php @@ -17,7 +17,7 @@ class IPF_ORM_Template_Orderable extends IPF_ORM_Template public function setTableDefinition() { - $this->hasColumn($this->columnName, 'integer', null, ''); + $this->hasColumn($this->columnName, 'integer', null, array('exclude' => true)); $this->getTable()->listeners['Orderable_'.$this->columnName] = new IPF_ORM_Template_Listener_Orderable($this->columnName); } } diff --git a/ipf/orm/validator/exclude.php b/ipf/orm/validator/exclude.php new file mode 100644 index 0000000..c97ea11 --- /dev/null +++ b/ipf/orm/validator/exclude.php @@ -0,0 +1,10 @@ +