Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 7a659dae0e
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 32 lines (24 sloc) 0.94 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
<?php
/**
* @author Weavora Team <hello@weavora.com>
* @link http://weavora.com
* @copyright Copyright (c) 2011 Weavora LLC
*/

// @todo TBD: I think it should be base class for related model types
class WFormRelation {

const RELATION_TYPE = 0;
const RELATION_CLASS = 1;
const RELATION_FOREIGN_KEY = 2;

public static function getInstance($model, $relationName, $relationInfo) {
switch($relationInfo[self::RELATION_TYPE]) {
case CActiveRecord::HAS_ONE: $relatedModel = new WFormRelationHasOne(); break;
case CActiveRecord::HAS_MANY: $relatedModel = new WFormRelationHasMany(); break;
case CActiveRecord::BELONGS_TO: $relatedModel = new WFormRelationBelongsTo(); break;
case CActiveRecord::MANY_MANY: $relatedModel = new WFormRelationManyMany(); break;
}

$relatedModel->model = $model;
$relatedModel->relationName = $relationName;
$relatedModel->relationInfo = $relationInfo;

return $relatedModel;
}


}
Something went wrong with that request. Please try again.