Skip to content

Commit 387b57d

Browse files
committed
remove / disable annotation references
1 parent 458097d commit 387b57d

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

src/Doctrine/EntityRegenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ private function createClassManipulator(string $classPath): ClassSourceManipulat
204204
// if properties need to be generated then, by definition,
205205
// some non-annotation config is being used, and so, the
206206
// properties should not have annotations added to them
207-
useAttributesForDoctrineMapping: false
207+
useAttributesForDoctrineMapping: true // We always want to use attributes?
208208
);
209209
}
210210

src/Maker/MakeController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ public function configureDependencies(DependencyBuilder $dependencies): void
120120
return;
121121
}
122122

123-
$dependencies->addClassDependency(
124-
Annotation::class,
125-
'doctrine/annotations'
126-
);
123+
// $dependencies->addClassDependency(
124+
// Annotation::class,
125+
// 'doctrine/annotations'
126+
// );
127127
}
128128

129129
private function isTwigInstalled(): bool

src/Maker/MakeRegistrationForm.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
143143

144144
// see if it makes sense to add the UniqueEntity constraint
145145
$userClassDetails = new ClassDetails($this->userClass);
146-
$addAnnotation = false;
147-
if (!$userClassDetails->doesDocBlockContainAnnotation('@UniqueEntity')) {
148-
$addAnnotation = $io->confirm(sprintf('Do you want to add a <comment>@UniqueEntity</comment> validation annotation on your <comment>%s</comment> class to make sure duplicate accounts aren\'t created?', Str::getShortClassName($this->userClass)));
146+
$addAttribute = false;
147+
if (!$userClassDetails->isClassUnique()) {
148+
$addAttribute = $io->confirm(sprintf('Do you want to add a <comment>#[UniqueEntity]</comment> validation attribute on your <comment>%s</comment> class to make sure duplicate accounts aren\'t created?', Str::getShortClassName($this->userClass)));
149149
}
150-
$this->addUniqueEntityConstraint = $addAnnotation;
150+
$this->addUniqueEntityConstraint = $addAttribute;
151151

152152
$this->willVerifyEmail = $io->confirm('Do you want to send an email to verify the user\'s email address after registration?', true);
153153

@@ -488,10 +488,10 @@ private function getMissingComponentsComposerMessage(): ?string
488488

489489
public function configureDependencies(DependencyBuilder $dependencies): void
490490
{
491-
$dependencies->addClassDependency(
492-
Annotation::class,
493-
'doctrine/annotations'
494-
);
491+
// $dependencies->addClassDependency(
492+
// Annotation::class,
493+
// 'doctrine/annotations'
494+
// );
495495

496496
$dependencies->addClassDependency(
497497
AbstractType::class,

src/Maker/MakeResetPassword.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function configureDependencies(DependencyBuilder $dependencies): void
122122

123123
ORMDependencyBuilder::buildDependencies($dependencies);
124124

125-
$dependencies->addClassDependency(Annotation::class, 'annotations');
125+
// $dependencies->addClassDependency(Annotation::class, 'annotations');
126126

127127
// reset-password-bundle 1.6 includes the ability to generate a fake token.
128128
// we need to check that version 1.6 is installed

src/Util/ClassDetails.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Bundle\MakerBundle\Util;
1313

14+
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
15+
1416
/**
1517
* @internal
1618
*/
@@ -61,6 +63,7 @@ public function getPath(): string
6163
* An imperfect, but simple way to check for the presence of an annotation.
6264
*
6365
* @param string $annotation The annotation - e.g. @UniqueEntity
66+
* @deprecated We dont support anntations anymore..
6467
*/
6568
public function doesDocBlockContainAnnotation(string $annotation): bool
6669
{
@@ -72,4 +75,11 @@ public function doesDocBlockContainAnnotation(string $annotation): bool
7275

7376
return str_contains($docComment, $annotation);
7477
}
78+
79+
public function isClassUnique(): bool
80+
{
81+
$reflected = new \ReflectionClass($this->fullClassName);
82+
83+
return !empty($reflected->getAttributes(UniqueEntity::class));
84+
}
7585
}

0 commit comments

Comments
 (0)