protected function getDefaultMappings() { $mappings = [self::TO_STORAGE => [], self::TO_ENTITY => []]; $columns = array_keys($this->platform->getForeignKeys($this->storageName)); foreach ($columns as $storageKey) { $entityKey = $this->formatEntityForeignKey($storageKey); $mappings[self::TO_ENTITY][$storageKey] = [$entityKey, null]; $mappings[self::TO_STORAGE][$entityKey] = [$storageKey, null]; } $storagePrimaryKey = $this->getStoragePrimaryKey(); if (count($this->entityPrimaryKey) !== count($storagePrimaryKey)) { throw new InvalidStateException('Mismatch count of entity primary key (' . implode(', ', $this->entityPrimaryKey) . ') with storage primary key (' . implode(', ', $storagePrimaryKey) . ').'); } if (count($storagePrimaryKey) === 1) { $entityKey = $this->entityPrimaryKey[0]; $storageKey = $storagePrimaryKey[0]; $mappings[self::TO_ENTITY][$storageKey] = [$entityKey, null]; $mappings[self::TO_STORAGE][$entityKey] = [$storageKey, null]; } return $mappings; }
public function getForeignKeys($table) { return $this->cache->load('foreign_keys.' . $table, function () use($table) { return $this->platform->getForeignKeys($table); }); }