Advertisement
fruffl

Marshal Types

Oct 9th, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.25 KB | None | 0 0
  1.  
  2. $types = [
  3.    
  4.     'authors' => [
  5.         iType::PROP_IDENTIFY_FIELD => 'id',
  6.         iManager::PROP_RELATION_NAMES => [
  7.             'posts' => [
  8.                 iRelation::PROP_RELATIONSHIP => 'HasMany',
  9.                 iRelation::PROP_NATIVE_FIELD => 'id',
  10.                 iRelation::PROP_FOREIGN_FIELD => 'authorId',
  11.             ],
  12.         ],
  13.     ],
  14.    
  15.     'posts' => [
  16.         iType::PROP_IDENTIFY_FIELD => 'id',
  17.         iType::PROP_INDEX_FIELDS => [
  18.             'authorId',
  19.         ],
  20.         iManager::PROP_RELATION_NAMES => [
  21.             'meta' => [
  22.                 iRelation::PROP_RELATIONSHIP => 'HasOne',
  23.                 iRelation::PROP_FOREIGN_TYPE => 'metas',
  24.                 iRelation::PROP_NATIVE_FIELD => 'id',
  25.                 iRelation::PROP_FOREIGN_FIELD => 'postId',
  26.             ],
  27.             'comments' => [
  28.                 iRelation::PROP_RELATIONSHIP => 'HasMany',
  29.                 iRelation::PROP_NATIVE_FIELD => 'id',
  30.                 iRelation::PROP_FOREIGN_FIELD => 'postId'
  31.             ],
  32.             'author' => [
  33.                 iRelation::PROP_RELATIONSHIP => 'BelongsTo',
  34.                 iRelation::PROP_FOREIGN_TYPE => 'authors',
  35.                 iRelation::PROP_NATIVE_FIELD => 'authorId',
  36.                 iRelation::PROP_FOREIGN_FIELD => 'id',
  37.             ],
  38.             'tags' => [
  39.                 iRelation::PROP_RELATIONSHIP => 'HasManyThrough',
  40.                 iRelation::PROP_THROUGH_TYPE => 'posts_tags',
  41.                 iRelation::PROP_NATIVE_FIELD => 'id',
  42.                 iRelation::PROP_THROUGH_NATIVE_FIELD => 'postId',
  43.                 iRelation::PROP_THROUGH_FOREIGN_FIELD => 'tagId',
  44.                 iRelation::PROP_FOREIGN_FIELD => 'id'
  45.             ],
  46.         ],
  47.     ],
  48.    
  49.     'metas' => [
  50.         iType::PROP_IDENTIFY_FIELD => 'id',
  51.         iType::PROP_INDEX_FIELDS => [
  52.             'postId',
  53.         ],
  54.         iManager::PROP_RELATION_NAMES => [
  55.             'post' => [
  56.                 iRelation::PROP_RELATIONSHIP => 'BelongsTo',
  57.                 iRelation::PROP_FOREIGN_TYPE => 'posts',
  58.                 iRelation::PROP_NATIVE_FIELD => 'postId',
  59.                 iRelation::PROP_FOREIGN_FIELD => 'id',
  60.             ],
  61.         ],
  62.     ],
  63.    
  64.     'comments' => [
  65.         iType::PROP_IDENTIFY_FIELD => 'id',
  66.         iType::PROP_INDEX_FIELDS => [
  67.             'postId',
  68.         ],
  69.         iManager::PROP_RELATION_NAMES => [
  70.             'post' => [
  71.                 iRelation::PROP_RELATIONSHIP => 'BelongsTo',
  72.                 iRelation::PROP_FOREIGN_TYPE => 'posts',
  73.                 iRelation::PROP_NATIVE_FIELD => 'postId',
  74.                 iRelation::PROP_FOREIGN_FIELD => 'id',
  75.             ],
  76.             'author' => [
  77.                 iRelation::PROP_RELATIONSHIP => 'BelongsTo',
  78.                 iRelation::PROP_FOREIGN_TYPE => 'authors',
  79.                 iRelation::PROP_NATIVE_FIELD => 'authorId',
  80.                 iRelation::PROP_FOREIGN_FIELD => 'id',
  81.             ],
  82.         ],
  83.     ],
  84.    
  85.     'posts_tags' => [
  86.         iType::PROP_IDENTIFY_FIELD => 'id',
  87.         iType::PROP_INDEX_FIELDS => [
  88.             'postId',
  89.             'tagId',
  90.         ],
  91.         iManager::PROP_RELATION_NAMES => [
  92.             'post' => [
  93.                 iRelation::PROP_RELATIONSHIP => 'BelongsTo',
  94.                 iRelation::PROP_FOREIGN_TYPE => 'posts',
  95.                 iRelation::PROP_NATIVE_FIELD => 'postId',
  96.                 iRelation::PROP_FOREIGN_FIELD => 'id',
  97.             ],
  98.             'tag' => [
  99.                 iRelation::PROP_RELATIONSHIP => 'BelongsTo',
  100.                 iRelation::PROP_FOREIGN_TYPE => 'tags',
  101.                 iRelation::PROP_NATIVE_FIELD => 'tagId',
  102.                 iRelation::PROP_FOREIGN_FIELD => 'id',
  103.             ],
  104.         ]
  105.     ],
  106.    
  107.     'tags' => [
  108.         iType::PROP_IDENTIFY_FIELD => 'id',
  109.         iManager::PROP_RELATION_NAMES => [
  110.             'posts' => [
  111.                 iRelation::PROP_RELATIONSHIP => 'HasManyThrough',
  112.                 iRelation::PROP_NATIVE_FIELD => 'id',
  113.                 iRelation::PROP_THROUGH_TYPE => 'posts_tags',
  114.                 iRelation::PROP_THROUGH_NATIVE_FIELD => 'tagId',
  115.                 iRelation::PROP_THROUGH_FOREIGN_FIELD => 'postId',
  116.                 iRelation::PROP_FOREIGN_FIELD => 'id'
  117.             ],
  118.         ],
  119.     ],
  120. ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement