cooptilleuls / cooptilleulsmigrationbundle Goto Github PK
View Code? Open in Web Editor NEWProvides basic features for continuous migration: it implements loaders & transformers.
License: MIT License
Provides basic features for continuous migration: it implements loaders & transformers.
License: MIT License
Our context:
We have a User that we want to soft delete
// Entity\User.php
/**
* @ApiResource(...)
*
* @ORM\EntityListeners({"AppBundle\EntityListener\UserEntityListener"})
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=true)
* @Transformer("AppBundle\Transformer\UserTransformer")
*/
class User implements UserInterface
{
//...
}
Issue:
We use the Transformer
, however our object does not pass through the delete()
of our UserTransformer
as it passed through the preRemove()
of the UserEntityListener
.
After research and testing, it seems that our object is under the class Proxies\__CG __\AppBundle\Entity\User
. However, in this case when passing through the getTransformerAnnotation()
function of the TransformerEventListener
, the @Transformer
annotation is not found by reflection. And thus hasTransformer()
return false, and in preRemove()
the event is not triggered.
Proposed solution:
I solve this issue, but I have to edit your bundle, this way:
// TransformerEventListener.php
private function getTransformerAnnotation($object)
{
$pattern = 'Proxies\\__CG__\\';
if (0 === strpos(get_class($object), $pattern)) {
$notProxiClassName = substr(get_class($object), strlen($pattern));
$object = new $notProxiClassName;
}
return $this->reader->getClassAnnotation(new \ReflectionClass($object), Transformer::class);
}
For you, is it really an issue to fix from your side, or would it be up to me to make sure not to have a class Proxies\__CG__\...
?
Thank you, and do not hesitate to ask for more information
It's impossible to use autowiring with parent
keyword:
services:
App\Loader\UserLoader:
class: App\Loader\UserLoader
parent: coop_tilleuls_migration.loader.abstract
autowire: false
autoconfigure: false
public: false
tags:
- { name: coop_tilleuls_migration.loader, alias: user }
Supports Symfony 3.3
Remove alias on tag declaration (improvement for autowiring)
With a default configuration, to prevent having this error during install:
The child node "legacy_connection_name" at path "coop_tilleuls_migration" must be configured.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.