From: Andrey Kutejko Date: Thu, 4 Jul 2013 17:45:21 +0000 (+0300) Subject: exclude relations from model forms X-Git-Tag: 0.6~99 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=30c3302851bb9fc5e04ef4f591a6721f93018284;p=ipf-legacy-orm.git exclude relations from model forms --- diff --git a/ipf/orm/import/builder.php b/ipf/orm/import/builder.php index ff9a5cb..d66b1b7 100644 --- a/ipf/orm/import/builder.php +++ b/ipf/orm/import/builder.php @@ -257,6 +257,10 @@ class IPF_ORM_Import_Builder $a[] = '\'owningSide\' => ' . self::varExport($relation['owningSide']); } + if (isset($relation['exclude']) && $relation['exclude']) { + $a[] = '\'exclude\' => ' . self::varExport($relation['exclude']); + } + if ( ! empty($a)) { $ret[$i] .= ', ' . 'array('; $length = strlen($ret[$i]); diff --git a/ipf/orm/import/schema.php b/ipf/orm/import/schema.php index 9a461f0..a17887d 100644 --- a/ipf/orm/import/schema.php +++ b/ipf/orm/import/schema.php @@ -461,7 +461,7 @@ class IPF_ORM_Import_Schema protected function _autoCompleteOppositeRelations() { foreach($this->_relations as $className => $relations) { - foreach ($relations AS $alias => $relation) { + foreach ($relations as $alias => $relation) { if ((isset($relation['equal']) && $relation['equal']) || (isset($relation['autoComplete']) && $relation['autoComplete'] === false)) { continue; } @@ -469,14 +469,14 @@ class IPF_ORM_Import_Schema $newRelation = array(); $newRelation['foreign'] = $relation['local']; $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; - + $newRelation['class'] = isset($relation['foreignClass']) ? $relation['foreignClass'] : $className; + $newRelation['alias'] = isset($relation['foreignAlias']) ? $relation['foreignAlias'] : $className; + $newRelation['exclude'] = isset($relation['foreignExclude']) ? $relation['foreignExclude'] : false; + // 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. $newRelation['autogenerated'] = true; - + if (isset($relation['refClass'])) { $newRelation['refClass'] = $relation['refClass']; $newRelation['type'] = isset($relation['foreignType']) ? $relation['foreignType']:$relation['type'];