Skip to content

Commit

Permalink
doctrine/orm 3 compability
Browse files Browse the repository at this point in the history
  • Loading branch information
muxx committed Oct 21, 2024
1 parent bbc405b commit c5be6b7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Command/IndexUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private function dropIndexes(array $indexesNames, array $customIndexes, Extended
private function dropIndex(ExtendedPlatform $platform, string $indexName): void
{
if ($this->input->getOption(self::DUMP_SQL_OPTION)) {
$this->output->writeln($platform->getDropIndexSQL($indexName) . ';');
$this->output->writeln($platform->getDropIndexSQL($indexName, '') . ';');

return;
}
Expand Down
23 changes: 19 additions & 4 deletions Metadata/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private function collect(
*/
private function getTableNameFromMetadata(ClassMetadata $metadata, ClassMetadata $parentMetadata): string
{
if (ClassMetadataInfo::INHERITANCE_TYPE_JOINED === $metadata->inheritanceType) {
if (ClassMetadata::INHERITANCE_TYPE_JOINED === $metadata->inheritanceType) {
return $parentMetadata->getTableName();
}

Expand All @@ -99,15 +99,15 @@ private function getTableNameFromMetadata(ClassMetadata $metadata, ClassMetadata
*/
private function getCustomIndexesAttributes(ClassMetadata $meta): array
{
return $meta->getReflectionClass()->getAttributes(Attribute\CustomIndex::class);
return $this->getMetaReflectionClass($meta)->getAttributes(Attribute\CustomIndex::class);
}

/**
* @param ClassMetadata<T> $meta
*/
private function isAbstract(ClassMetadata $meta): bool
{
return $meta->getReflectionClass()->isAbstract();
return $this->getMetaReflectionClass($meta)->isAbstract();
}

/**
Expand Down Expand Up @@ -135,7 +135,7 @@ private function getAbstractClassesInfo(array $metadata): array
*/
private function searchParentsWithIndex(ClassMetadata $meta, array $abstractClasses): array
{
$reflectionClass = $meta->getReflectionClass();
$reflectionClass = $this->getMetaReflectionClass($meta);
$parentMeta = [];
foreach ($abstractClasses as $entityName => $entityMeta) {
if ($reflectionClass->isSubclassOf($entityName)) {
Expand All @@ -145,4 +145,19 @@ private function searchParentsWithIndex(ClassMetadata $meta, array $abstractClas

return $parentMeta;
}

/**
* @param ClassMetadata<T> $meta
*
* @return \ReflectionClass<T>
*/
private function getMetaReflectionClass(ClassMetadata $meta): \ReflectionClass
{
$reflectionClass = $meta->getReflectionClass();
if (null === $reflectionClass) {
throw new \RuntimeException('Reflection class is not found for ' . $meta->getName());
}

return $reflectionClass;
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}],
"require": {
"php": "^8.1",
"doctrine/orm": "^2.2.3",
"doctrine/orm": "^2.2.3 || ^3.0",
"symfony/config": "^5.0 || ^6.0",
"symfony/console": "^5.0 || ^6.0",
"symfony/dependency-injection": "^5.0 || ^6.0",
Expand Down

0 comments on commit c5be6b7

Please sign in to comment.