Skip to content

Commit

Permalink
Handle support dropped for Annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
hackzilla committed Jul 29, 2023
1 parent 56b4706 commit 7f2a940
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions Maker/AbstractMaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,17 @@ abstract protected function interfaces(): array;
private function createClassManipulator(string $path, ConsoleStyle $io, bool $overwrite, string $className, bool $originalClass = true): ClassSourceManipulator
{
$useAttributes = $this->doctrineHelper->doesClassUsesAttributes($className) && $this->doctrineHelper->isDoctrineSupportingAttributes();
$useAnnotations = $this->doctrineHelper->isClassAnnotated($className) || !$useAttributes;
$useAnnotations = false ;

if (method_exists($this->doctrineHelper, 'isClassAnnotated')) {
$useAnnotations = $this->doctrineHelper->isClassAnnotated($className) ||!$useAttributes;
}

dump($useAttributes, $useAnnotations);

if (!$useAnnotations && !$useAttributes) {
throw new \Exception('No support for either Annotations or Attributes');
}

$manipulator = new ClassSourceManipulator($this->fileManager->getFileContents($path), $overwrite, $useAnnotations, true, $useAttributes);

Expand Down Expand Up @@ -274,15 +284,15 @@ private function doesEntityUseAnnotationMapping(string $className): bool
$className = reset($otherClassMetadatas)->getName();
}

if (!method_exists($this->doctrineHelper, 'isClassAnnotated')) {
return false;
}

return $this->doctrineHelper->isClassAnnotated($className);
}

private function doesEntityUseAttributeMapping(string $className): bool
{
if (\PHP_VERSION < 80000) {
return false;
}

if (!class_exists($className)) {
$otherClassMetadatas = $this->doctrineHelper->getMetadata(Str::getNamespace($className).'\\', true);

Expand Down

0 comments on commit 7f2a940

Please sign in to comment.