Skip to content

Commit

Permalink
Merge pull request #3 from odandb/inject
Browse files Browse the repository at this point in the history
Inject le property info & property access
  • Loading branch information
magi-web authored Dec 7, 2021
2 parents 74db89d + 5684af8 commit 3b66b13
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"roave/security-advisories": "dev-latest",
"symfony/phpunit-bridge": "^5.1 || ^6.0"
},
"suggest": {
"phpdocumentor/reflection-docblock": "To use the PHPDoc"
},
"config": {
"sort-packages": true
},
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/encryption-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ services:

Odandb\DoctrineCiphersweetEncryptionBundle\Services\PropertyHydratorService:
class: Odandb\DoctrineCiphersweetEncryptionBundle\Services\PropertyHydratorService
arguments:
- '@property_info'
- '@property_accessor'

Odandb\DoctrineCiphersweetEncryptionBundle\Encryptors\EncryptorInterface:
class: Odandb\DoctrineCiphersweetEncryptionBundle\Encryptors\CiphersweetEncryptor
Expand Down
15 changes: 5 additions & 10 deletions src/Services/PropertyHydratorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,19 @@

use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
use Symfony\Component\PropertyInfo\Type;

class PropertyHydratorService
{
private PropertyInfoExtractor $propertyInfoExtractor;
private PropertyInfoExtractorInterface $propertyInfoExtractor;

private PropertyAccessorInterface $propertyAccessor;

public function __construct()
public function __construct(PropertyInfoExtractorInterface $propertyInfoExtractor, PropertyAccessorInterface $propertyAccessor = null)
{
$phpDocExtractor = new PhpDocExtractor();
$reflectionExtractor = new ReflectionExtractor();
$typeExtractors = [$phpDocExtractor, $reflectionExtractor];
$this->propertyInfoExtractor = new PropertyInfoExtractor([], $typeExtractors);
$this->propertyAccessor = PropertyAccess::createPropertyAccessor();
$this->propertyInfoExtractor = $propertyInfoExtractor;
$this->propertyAccessor = $propertyAccessor ?? PropertyAccess::createPropertyAccessor();
}

/**
Expand Down

0 comments on commit 3b66b13

Please sign in to comment.