コード例 #1
0
 /**
  * {@inheritdoc}
  */
 protected function clarifyDefinition()
 {
     parent::clarifyDefinition();
     if (empty($this->definition[RecordEntity::PIVOT_TABLE])) {
         $this->definition[RecordEntity::PIVOT_TABLE] = $this->getPivotTable();
     }
     if (!$this->isSameDatabase()) {
         throw new RelationSchemaException("Many-to-Many relation can create relations ({$this}) only to entities from same database.");
     }
 }
コード例 #2
0
 /**
  * Normalize schema definition into light cachable form.
  *
  * @return array
  */
 protected function normalizeDefinition()
 {
     $definition = parent::normalizeDefinition();
     if ($this->getOuterKey() == $this->outerRecord()->getPrimaryKey()) {
         //Linked using primary key
         $definition[ORM::M_PRIMARY_KEY] = $this->getOuterKey();
     }
     return $definition;
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 protected function proposedDefinitions()
 {
     $options = parent::proposedDefinitions();
     foreach ($this->outerRecords() as $record) {
         //We can use first found record primary key to populate default value
         $options['outer:primaryKey'] = $record->getPrimaryKey();
         break;
     }
     return $options;
 }