Skip to content

Commit

Permalink
Fix without annotation service
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhelias committed Nov 3, 2023
1 parent 3e3c2fc commit 73bba09
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

->set('encryption.subscriber', DoctrineCiphersweetSubscriber::class)
->args([
service('annotation_reader'), // @deprecated
service('annotation_reader')->nullOnInvalid(), // @deprecated
service('encryption.encrypted_fields'),
service(EncryptorInterface::class),
service('encryption.indexable_field'),
Expand All @@ -109,7 +109,7 @@

->set('encryption.encrypted_fields', EncryptedFieldsService::class)
->args([
service('annotation_reader'), // @deprecated
service('annotation_reader')->nullOnInvalid(), // @deprecated
])
;
};
6 changes: 3 additions & 3 deletions src/Services/EncryptedFieldsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
class EncryptedFieldsService
{
/** @deprecated */
private Reader $annReader;
private ?Reader $annReader;

public function __construct(Reader $annReader)
public function __construct(?Reader $annReader)
{
$this->annReader = $annReader;
}
Expand All @@ -38,7 +38,7 @@ public function getEncryptedFields(ClassMetadata $meta): array
}

/** @var \ReflectionProperty $refProperty */
if ($this->annReader->getPropertyAnnotation($refProperty, EncryptedField::class)) {
if (null !== $this->annReader && $this->annReader->getPropertyAnnotation($refProperty, EncryptedField::class)) {
$refProperty->setAccessible(true);
$encryptedFields[] = $refProperty;

Expand Down
6 changes: 3 additions & 3 deletions src/Subscribers/DoctrineCiphersweetSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DoctrineCiphersweetSubscriber implements EventSubscriberInterface, ResetIn
public const INDEXABLE_ANN_NAME = IndexableField::class;

/** @deprecated */
private Reader $annReader;
private ?Reader $annReader;
private EncryptorInterface $encryptor;
private IndexableFieldsService $indexableFieldsService;
private PropertyHydratorService $propertyHydratorService;
Expand Down Expand Up @@ -77,7 +77,7 @@ class DoctrineCiphersweetSubscriber implements EventSubscriberInterface, ResetIn
private array $entitiesToEncrypt = [];

public function __construct(
Reader $annReader,
?Reader $annReader,
EncryptedFieldsService $encryptedFieldsService,
EncryptorInterface $encryptorClass,
IndexableFieldsService $indexableFieldsService,
Expand Down Expand Up @@ -330,7 +330,7 @@ private function buildContext(string $entityClassName, \ReflectionProperty $refP
}
}

if (null === $annotationConfig && null === $indexableAnnotationConfig) {
if (null === $annotationConfig && null === $indexableAnnotationConfig && null !== $this->annReader) {
$annotationConfig = $this->annReader->getPropertyAnnotation($refProperty, self::ENCRYPTED_ANN_NAME);
$indexableAnnotationConfig = $this->annReader->getPropertyAnnotation($refProperty, self::INDEXABLE_ANN_NAME);

Expand Down
1 change: 1 addition & 0 deletions tests/App/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ imports:
- { resource: services.yaml }

framework:
annotations: false
secret: '123456789'
http_method_override: false
router:
Expand Down

0 comments on commit 73bba09

Please sign in to comment.