/** * {@inheritdoc} */ protected function clarifyDefinition() { parent::clarifyDefinition(); if (!$this->isSameDatabase()) { throw new RelationSchemaException("Many-to-Many morphed relation can create relations ({$this}) " . "only to entities from same database."); } }
/** * Normalize schema definition into light cachable form. * * @return array */ protected function normalizeDefinition() { $definition = parent::normalizeDefinition(); if (empty($this->outerRecords())) { return $definition; } //We should only check first record since they all must follow same key if ($this->getOuterKey() == $this->outerRecords()[0]->getPrimaryKey()) { //Linked using primary key $definition[ORM::M_PRIMARY_KEY] = $this->getOuterKey(); } return $definition; }