Example #1
0
 /**
  * Define the joined hydration schema based on a join object.
  * Fills the ModelWith properties using a ModelJoin as source
  *
  * @param ModelJoin $join
  */
 public function init(ModelJoin $join)
 {
     $tableMap = $join->getTableMap();
     $this->modelName = $tableMap->getClassname();
     $this->modelPeerName = $tableMap->getPeerClassname();
     $this->isSingleTableInheritance = $tableMap->isSingleTableInheritance();
     $relation = $join->getRelationMap();
     if ($relation->getType() == RelationMap::ONE_TO_MANY) {
         $this->isAdd = true;
         $this->relationName = $relation->getName() . 's';
         $this->relationMethod = 'add' . $relation->getName();
     } else {
         $this->relationName = $relation->getName();
         $this->relationMethod = 'set' . $relation->getName();
     }
     if (!$join->isPrimary()) {
         $this->relatedClass = $join->hasLeftTableAlias() ? $join->getLeftTableAlias() : $relation->getLeftTable()->getPhpName();
     }
 }
Example #2
0
 /**
  * Define the joined hydration schema based on a join object.
  * Fills the ModelWith properties using a ModelJoin as source
  *
  * @param ModelJoin $join
  */
 public function init(ModelJoin $join)
 {
     $tableMap = $join->getTableMap();
     $this->modelName = $tableMap->getClassname();
     $this->modelPeerName = $tableMap->getPeerClassname();
     $this->isSingleTableInheritance = $tableMap->isSingleTableInheritance();
     $relation = $join->getRelationMap();
     $relationName = $relation->getName();
     if ($relation->getType() == RelationMap::ONE_TO_MANY) {
         $this->isAdd = $this->isWithOneToMany = true;
         $this->relationName = $relationName . 's';
         $this->relationMethod = 'add' . $relationName;
         $this->initMethod = 'init' . $relationName . 's';
     } else {
         $this->relationName = $relationName;
         $this->relationMethod = 'set' . $relationName;
     }
     $this->rightPhpName = $join->hasRelationAlias() ? $join->getRelationAlias() : $relationName;
     if (!$join->isPrimary()) {
         $this->leftPhpName = $join->hasLeftTableAlias() ? $join->getLeftTableAlias() : $join->getPreviousJoin()->getRelationMap()->getName();
     }
 }