diff --git a/Command/IndexUpdateCommand.php b/Command/IndexUpdateCommand.php index 3a30cf7..7b28a40 100644 --- a/Command/IndexUpdateCommand.php +++ b/Command/IndexUpdateCommand.php @@ -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; } diff --git a/Metadata/Reader.php b/Metadata/Reader.php index 3fd2212..8b1c766 100644 --- a/Metadata/Reader.php +++ b/Metadata/Reader.php @@ -4,7 +4,6 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\ClassMetadataInfo; use Intaro\CustomIndexBundle\DTO\CustomIndex; /** @@ -85,7 +84,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(); } @@ -99,7 +98,7 @@ 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); } /** @@ -107,7 +106,7 @@ private function getCustomIndexesAttributes(ClassMetadata $meta): array */ private function isAbstract(ClassMetadata $meta): bool { - return $meta->getReflectionClass()->isAbstract(); + return $this->getMetaReflectionClass($meta)->isAbstract(); } /** @@ -135,7 +134,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)) { @@ -145,4 +144,19 @@ private function searchParentsWithIndex(ClassMetadata $meta, array $abstractClas return $parentMeta; } + + /** + * @param ClassMetadata $meta + * + * @return \ReflectionClass + */ + 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; + } } diff --git a/composer.json b/composer.json index cb79799..c5bc39d 100644 --- a/composer.json +++ b/composer.json @@ -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",