]> git.andy128k.dev Git - ipf.git/commitdiff
'exclude' and 'foreignExclude' model options.
authorAndrey Kutejko <andy128k@gmail.com>
Sun, 30 Jun 2013 21:28:03 +0000 (00:28 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sun, 30 Jun 2013 21:28:03 +0000 (00:28 +0300)
exclude ord in Orderable template

ipf/form/model.php
ipf/orm/import/schema.php
ipf/orm/relation.php
ipf/orm/template/orderable.php
ipf/orm/validator/exclude.php [new file with mode: 0644]

index acfa6d4ba307c7dc379218a98c2e26d55a251c2b..1bf2cdf14cf20f2284de2a561840942674e0c966 100644 (file)
@@ -26,14 +26,13 @@ class IPF_Form_Model extends IPF_Form
                 $exclude = array();
 
             foreach ($db_columns as $name => $col) {
-                if (array_search($name, $exclude) !== false)
-                    continue;
-                $this->addDBField($name, $col);
+                if (array_search($name, $exclude) === false && !isset($col['exclude']))
+                    $this->addDBField($name, $col);
             }
+
             foreach ($db_relations as $name => $relation) {
-                if (array_search($name, $exclude) !== false)
-                    continue;
-                $this->addDBRelation($name, $relation, $col);
+                if (array_search($name, $exclude) === false && !isset($relation['exclude']))
+                    $this->addDBRelation($name, $relation, $col); // FIXME: $col is undefined
             }
         } else {
             foreach ($user_fields as $uname) {
index a4c67c27367f6cd1950d6f4ccf356fc7a3bf17b7..9a461f08bf83cd1e127a99c3821c675dfd5b52b8 100644 (file)
@@ -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.
index 74271970e87ff5bc266ef52e0e02ea1a273fe0fd..8c43bccba34b80a8fa956535bcdf573570c8198e 100644 (file)
@@ -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)
index 1935e70a1c02a13c2d6376ebd86f0d5e21414f96..0d26546c354b599ac8fe9ef91066cb5a212f7f54 100644 (file)
@@ -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 (file)
index 0000000..c97ea11
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+class IPF_ORM_Validator_Exclude
+{
+    public function validate($value)
+    {
+        return true;
+    }
+}
+