コード例 #1
0
ファイル: Table.php プロジェクト: imranweb7/msitc-erp
 private function set_associations()
 {
     require_once 'Relationship.php';
     $namespace = $this->class->getNamespaceName();
     foreach ($this->class->getStaticProperties() as $name => $definitions) {
         if (!$definitions) {
             # || !is_array($definitions))
             continue;
         }
         foreach (wrap_strings_in_arrays($definitions) as $definition) {
             $relationship = null;
             $definition += compact('namespace');
             switch ($name) {
                 case 'has_many':
                     $relationship = new HasMany($definition);
                     break;
                 case 'has_one':
                     $relationship = new HasOne($definition);
                     break;
                 case 'belongs_to':
                     $relationship = new BelongsTo($definition);
                     break;
                 case 'has_and_belongs_to_many':
                     $relationship = new HasAndBelongsToMany($definition);
                     break;
             }
             if ($relationship) {
                 $this->add_relationship($relationship);
             }
         }
     }
 }
コード例 #2
0
 private function setAssociations()
 {
     require_once 'Relationship.php';
     foreach ($this->class->getStaticProperties() as $name => $definitions) {
         if (!$definitions) {
             # || !is_array($definitions))
             continue;
         }
         foreach (wrap_strings_in_arrays($definitions) as $definition) {
             $relationship = null;
             switch ($name) {
                 case 'hasMany':
                     $relationship = new HasMany($definition);
                     break;
                 case 'hasOne':
                     $relationship = new HasOne($definition);
                     break;
                 case 'belongsTo':
                     $relationship = new BelongsTo($definition);
                     break;
                 case 'hasAndBelongsToMany':
                     $relationship = new HasAndBelongsToMany($definition);
                     break;
             }
             if ($relationship) {
                 $this->addRelationship($relationship);
             }
         }
     }
 }