Skip to content

Commit

Permalink
Merge pull request firmaprofesional#2 from firmaprofesional/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dbonfill authored Mar 25, 2021
2 parents 42e13b1 + b18011e commit f1574b8
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions Subscribers/AbstractDoctrineEncryptSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Doctrine\Common\EventSubscriber;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use \ReflectionClass;
use FP\DoctrineEncryptBundle\Encryptors\EncryptorInterface;
use FP\DoctrineEncryptBundle\Configuration\Encrypted;
Expand All @@ -22,10 +22,10 @@ abstract class AbstractDoctrineEncryptSubscriber implements EventSubscriber {
* Encrypted annotation full name
*/
const ENCRYPTED_ANN_NAME = 'FP\DoctrineEncryptBundle\Configuration\Encrypted';

/**
* Encryptor
* @var EncryptorInterface
* @var EncryptorInterface
*/
protected $encryptor;

Expand All @@ -43,10 +43,10 @@ abstract class AbstractDoctrineEncryptSubscriber implements EventSubscriber {

/**
* Initialization of subscriber
* @param string $encryptorClass The encryptor class. This can be empty if
* @param string $encryptorClass The encryptor class. This can be empty if
* a service is being provided.
* @param string $secretKey The secret key.
* @param EncryptorServiceInterface|NULL $service (Optional) An EncryptorServiceInterface.
* @param string $secretKey The secret key.
* @param EncryptorServiceInterface|NULL $service (Optional) An EncryptorServiceInterface.
* This allows for the use of dependency injection for the encrypters.
*/
public function __construct(Reader $annReader, EncryptorInterface $service) {
Expand All @@ -57,22 +57,22 @@ public function __construct(Reader $annReader, EncryptorInterface $service) {
/**
* Listen a prePersist lifecycle event. Checking and encrypt entities
* which have <code>@Encrypted</code> annotation
* @param LifecycleEventArgs $args
* @param LifecycleEventArgs $args
*/
abstract public function prePersist($args);

/**
* Listen a preUpdate lifecycle event. Checking and encrypt entities fields
* which have <code>@Encrypted</code> annotation. Using changesets to avoid preUpdate event
* restrictions
* @param LifecycleEventArgs $args
* @param LifecycleEventArgs $args
*/
abstract public function preUpdate($args);

/**
* Listen a postLoad lifecycle event. Checking and decrypt entities
* which have <code>@Encrypted</code> annotations
* @param LifecycleEventArgs $args
* @param LifecycleEventArgs $args
*/
abstract public function postLoad($args);

Expand All @@ -98,7 +98,7 @@ public static function capitalize($word) {
/**
* Process (encrypt/decrypt) entities fields
* @param Obj $object Some doctrine entity
* @param Boolean $isEncryptOperation If true - encrypt, false - decrypt entity
* @param Boolean $isEncryptOperation If true - encrypt, false - decrypt entity
*/
protected function processFields($object, $isEncryptOperation = true) {
$encryptorMethod = $isEncryptOperation ? 'encrypt' : 'decrypt';
Expand Down Expand Up @@ -142,7 +142,7 @@ private function determineNewValue(Encrypted $annotation, $currentValue, $object


/**
* This method can be overridden to handle a specific data type differently.
* This method can be overridden to handle a specific data type differently.
* IE. Override this to handle arrays specifically with MongoDB.
* @param type $encryptorMethod
* @param type $value
Expand All @@ -155,10 +155,10 @@ protected function handleValue($encryptorMethod, $value, $deterministic) {
/**
* Check if we have entity in decoded registry
* @param Object $entity Some doctrine entity
* @param Doctrine\Common\Persistence\ObjectManager $em
* @param EntityManagerInterface $em
* @return boolean
*/
protected function hasInDecodedRegistry($entity, ObjectManager $om) {
protected function hasInDecodedRegistry($entity, EntityManagerInterface $om) {
$className = get_class($entity);
$metadata = $om->getClassMetadata($className);
try {
Expand All @@ -178,9 +178,9 @@ protected function hasInDecodedRegistry($entity, ObjectManager $om) {
/**
* Adds entity to decoded registry
* @param object $entity Some doctrine entity
* @param Doctrine\Common\Persistence\ObjectManager $em
* @param EntityManagerInterface $em
*/
protected function addToDecodedRegistry($entity, ObjectManager $om) {
protected function addToDecodedRegistry($entity, EntityManagerInterface $om) {
return;
$className = get_class($entity);
$metadata = $om->getClassMetadata($className);
Expand All @@ -207,13 +207,12 @@ protected function getAnnotation(ReflectionProperty $reflectionProperty) {
}

/**
*
*
* @param mixed $object
* @return ReflectionProperty[]
*/
protected function getReflectionProperties($object) {
$reflectionClass = new ReflectionClass($object);
return $reflectionClass->getProperties();
}

}

0 comments on commit f1574b8

Please sign in to comment.