Closed rubenrubiob closed 5 years ago
Honestly, both ought to be private, it's probably just an oversight or leftover legacy. This class was originally written in a time before the final
keyword, otherwise it would have it.
Rather than extending the middleware, I would recommend just duplicating the code OR splitting your file rollback into a separate middleware entirely.
Hope that helps clarify the situation! :)
Yes, it helps a lot! I would duplicate the code.
I can not move my file rollback to another middleware. That is how I had it first, but then, if the file or database commit failed, there would be inconsistencies as only one rollback would be performed.
Thank you!
Hi there!
I am using this package and recently and recently I have come across a problematic situation. The thing is that I am uploading files and saving its information in the database. But I want to upload them in a transactional way, i.e., avoid uploading the file if there is an error in the database, or avoid saving the record in the database if there is an error moving the file.
For that purpose I have created a Middleware that extends from this packages'
TransactionMiddleware
, where I start the transaction, commit it or rollback it for both the database and the filesystem.I am using the protected method
rollbackTransaction
ofTransactionMiddleware
in order to rollback the transaction using the code that is already written. But I had to redeclare theentityManager
attribute in my class, as it is private.That is my question: why is the
entityManager
attribute private whilst therollbackTransaction
method is protected?I understand that if the
rollbackTransaction
is protected and theTransactionMiddleware
is not declared asfinal
, the class can be extended. But then maybe theentityManager
attribute should be declared as protected? Or the opposite, if the class should not be extended, both must be private.That is my question, just an clarification :)
Thank you for this package!
Regards!