My FIU Curriculum Class Reference. Yii Framework

Group

Package application
Inheritance class Group » VersionedEntity
Source Code
Description of Group

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
VersionedEntity() VersionedEntity
createNewHistoryRecord() Updates the entity CREATING a new history record Group
entityExistsCurr() Group
entityExistsHis() Group
findEntity() Finds an entity of the table with the most recent history. Group
getMostResentActivatedVersionForEntity() VersionedEntity
newEntity() Creates a new entity (saves to database) Group
updateHistoryRecord() Updates the entity WITHOUT CREATING a new history record Group

Method Details

Group() method
public void Group(type $entityId, type $catalogId)
$entityId type
$catalogId type
Source Code: (show)
public function Group($entityId$catalogId){
    
$this->his_tableName 'his_group';
    
parent::VersionedEntity($entityId$catalogId);
}

Constructor

createNewHistoryRecord() method
protected BOOLEAN createNewHistoryRecord()
{return} BOOLEAN
Source Code: (show)
protected function createNewHistoryRecord() {
    
    
$hisRecord $this->entity->hisGroups[0];
    
$newHisRecord = new HisGroup();
    
$newHisRecord->setAttributes($hisRecord->attributes);
    
$newHisRecord->unsetAttributes(array('id'));
    
$newHisRecord->setIsNewRecord(true);
    
$newHisRecord->catalog_id $this->catalog_id;
    
    return 
$newHisRecord->save();
    
    
}

Updates the entity CREATING a new history record

entityExistsCurr() method
protected static void entityExistsCurr(AR $model)
$model AR
Source Code: (show)
protected static function entityExistsCurr($model) {
   return 
CurrGroup::model()->exists('id=:id', array(':id'=>$model->id));
}

entityExistsHis() method
protected static void entityExistsHis($model)
$model
Source Code: (show)
protected static function entityExistsHis($model) {
    return 
HisGroup::model()->exists('id=:id', array(':id'=>$model->id));
}

findEntity() method
protected AR findEntity(type $entityId)
$entityId type
{return} AR entity with most recent history
Source Code: (show)
protected function findEntity($entityId) {        
    
    
    
//SELECT * FOROM curr_table, his_table 
    //  WHERE id = $entityId AND his_table.catalog_id=$$versionId
    
$entity CurrGroup::model()->with('hisGroups')->find('t.id=:entityId AND hisGroups.catalog_id=:versionId',
            array(
':entityId'=>$entityId':versionId'=> $this->catalog_id ));
    
    
    
//if version of history does not exists, find the most reasent one
    
if(is_null($entity)){
        
        
//get the most resent active version on the his_table
        
$mostResentActiveVersion $this->getMostResentActivatedVersionForEntity($entityId$this->his_tableName);
        
        
        
//SELECT * FOROM curr_table, his_table
        // WHERE id = $entityId AND his_table.catalog_id=$mostResentActiveVersion['id']
        
$entity CurrGroup::model()->with('hisGroups')->find('t.id=:entityId AND hisGroups.catalog_id=:versionId',
            array(
':entityId'=>$entityId':versionId'=> $mostResentActiveVersion['id']));
        
    }
    
    
//Return the entity Active Record
    
return $entity;
}

Finds an entity of the table with the most recent history. It is used by a wrapper on the parent class to set the member entity.

getHistoryEntities() method
public void getHistoryEntities()
Source Code: (show)
public function getHistoryEntities() {
    return 
HisGroup::model()->findAll('identifier_id=:entityId', array('entityId'=>$this->entity->id));
    
}

getHistoryEntity() method
public void getHistoryEntity()
Source Code: (show)
public function getHistoryEntity() {
    return 
$this->entity->hisGroups[0];
    
}

newEntity() method
protected static int newEntity(AR $currModel, AR $hisModel)
$currModel AR
$hisModel AR
{return} int Id of new entity
Source Code: (show)
protected static function newEntity($currModel$hisModel) {
    
    
// create identifier (base)
    
if($currModel->save()){
        
        
$hisModel->identifier_id $currModel->id;
        
        if(
$hisModel->save()){
            return 
$currModel->id;
        }
        else{
            throw new 
Exception("cannot create hisModel for identifier: ".$currModel->id);
        }
    }
    else{
        throw new 
Exception("cannot create currModel");
    }
    
}

Creates a new entity (saves to database) creates the identifier record (curr_table), and then the data (his_table)

updateHistoryRecord() method
protected BOOLEAN updateHistoryRecord()
{return} BOOLEAN
Source Code: (show)
protected function updateHistoryRecord() {
    
$hisRecord $this->entity->hisGroups[0];
    return 
$hisRecord->save();
}

Updates the entity WITHOUT CREATING a new history record

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.