/** * @param CrossForeignKeys $crossFKs * @param ForeignKey $excludeFK * @return string */ protected function getCrossRefFKRemoveObjectNames(CrossForeignKeys $crossFKs, ForeignKey $excludeFK) { $names = []; $fks = $crossFKs->getCrossForeignKeys(); foreach ($crossFKs->getMiddleTable()->getForeignKeys() as $fk) { if ($fk !== $excludeFK && ($fk === $crossFKs->getIncomingForeignKey() || in_array($fk, $fks))) { if ($fk === $crossFKs->getIncomingForeignKey()) { $names[] = '$this'; } else { $names[] = '$' . lcfirst($this->getFKPhpNameAffix($fk, false)); } } } foreach ($crossFKs->getUnclassifiedPrimaryKeys() as $pk) { $names[] = '$' . lcfirst($pk->getPhpName()); } return implode(', ', $names); }
/** * Extracts some useful information from a CrossForeignKeys object. * * @param CrossForeignKeys $crossFKs * @param array|ForeignKey $crossFKToIgnore * @param array $signature * @param array $shortSignature * @param array $normalizedShortSignature * @param array $phpDoc */ protected function extractCrossInformation(CrossForeignKeys $crossFKs, $crossFKToIgnore = null, &$signature, &$shortSignature, &$normalizedShortSignature, &$phpDoc) { foreach ($crossFKs->getCrossForeignKeys() as $fk) { if (is_array($crossFKToIgnore) && in_array($fk, $crossFKToIgnore)) { continue; } else { if ($fk === $crossFKToIgnore) { continue; } } $phpType = $typeHint = $this->getClassNameFromTable($fk->getForeignTable()); $name = '$' . lcfirst($this->getFKPhpNameAffix($fk)); $normalizedShortSignature[] = $name; $signature[] = ($typeHint ? "{$typeHint} " : '') . $name; $shortSignature[] = $name; $phpDoc[] = "\n * @param {$phpType} {$name}"; } foreach ($crossFKs->getUnclassifiedPrimaryKeys() as $primaryKey) { //we need to add all those $primaryKey s as additional parameter as they are needed //to create the entry in the middle-table. $defaultValue = $primaryKey->getDefaultValueString(); $phpType = $primaryKey->getPhpType(); $typeHint = $primaryKey->isPhpArrayType() ? 'array' : ''; $name = '$' . lcfirst($primaryKey->getPhpName()); $normalizedShortSignature[] = $name; $signature[] = ($typeHint ? "{$typeHint} " : '') . $name . ('null' !== $defaultValue ? " = {$defaultValue}" : ''); $shortSignature[] = $name; $phpDoc[] = "\n * @param {$phpType} {$name}"; } }