-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overriding entity doesn't work #55
Comments
Hi @lukepass ! Thanks for using the bundle ! At first glance it seems like your configuration has a typo : inside the It should work if you remove the empty |
Hello @maximilienGilet and thanks for the fast response!
Now I am using an entity called AppNotification and it seems to work but I had to change the table name:
Is this how it's supposed to work? Thanks! |
Hi @lukepass didn't test it yet, but maybe the Single table inheritance could fix this issue. However, it seems this annotations need to be added in the |
Hi @maximilienGilet, so clearly there is an issue right here with the bundle when you are trying to override the default entities. The best way should be to make do a refactoring and provide 3 models classes ( For Symfony Flex users, it will be perfect to create a recipe who provide the entity classes. @maximilienGilet What do you think about this idea? |
Hi @emulienfou this is a great idea ! However I don't use the bundle anymore and don't have much time to make the changes... Make me a pull request and I'll try and merge it :) |
Unfortunately I don't use Flex or Symfony 4. I tried with the single table inheritance but it didn't work well. |
Hi @lukepass, I'm currently using SF4 so it would be great if you can test it on your Symfony version. However, you will need to use my repository and add the following lines to your {
"repositories": [
{ "type": "vcs", "url": "https://github.com/emulienfou/notification-bundle" }
]
} Updated documentation to create entities and add Doctrine resolving mapping is here: https://github.com/emulienfou/notification-bundle/blob/master/Resources/doc/index.rst#add-entity-classes-non-symfony-flex-user Let me know if there is an issue on your side, I will make some fixes before creating the Pull Request and adding the Symfony Flex recipe |
Hi @emulienfou is your version overriding the entities right with SF4? |
Hi @danielrestrepo exactly, the updated code do not provide entities anymore, only mapped superclasses. Do not forget to add the doctrine configuration too, with the |
Thanks a lot @emulienfou custom mapping works now but I wanted to use the NotificationManager and I ran into a couple of issues as accessor methods are expecting the abstract class and not the interface like here: https://github.com/emulienfou/notification-bundle/blob/master/Model/NotificationInterface.php#L78 If I use there the NotifiableNotificationInterface error would go away. Am I right? Can I send you a PR with those changes? |
Hi @danielrestrepo just made the changes to use the interface instead of the model class. |
Thanks @emulienfou I'll update from your last commit and test again. For now the only additional thing I found is that $notification = $this->notification->createNotification('Proceso asignado');
$notification->setMessage('EL proceso xxx del 2019-04-02 le ha sido asignado');
$notification->setDate(new \DateTime());
$stepEvents = $event->getFlowEvents();
$user = null;
foreach ($stepEvents as $stepEvent) {
if ($stepEvent instanceof AssignUserEvent) {
/** @var UserInterface $user */
$user = $this->repositoryRegistry->getUserRepository()->find($stepEvent->getUserId()->toString());
}
}
$this->notification->addNotification([$user], $notification, true); Using original bundle without custom mappings was working with the same code. Not sure if it is the NotificationManager. Any ideas? Update I just needed to add Thanks anyway. It's been a pleasure collaborating with you |
Hi @danielrestrepo I apply the changes your made using interfaces in all models. |
Hi @emulienfou got back to your fork and is working nicely. Thanks a lot. I'll let you know if found something worth mentioning. |
Hello, I tried overriding the existing
1. Here is the overridden entity
2. Here is doctrine.yml
3. Here is what I try to achieve in my Controller
@maximilienGilet @emulienfou |
So, it worked because you have to create an Instance of the new overridden entity rather than creating the other entity. That fixed it for me |
Hi guys, |
Hi @marcin-dorosiewicz, you can follow up to Step No 2 here. After that in the controller use dependency injection to get the overridden notification class. Create an instance of the overridden notification class. And pass it into $manager->addNotification(). However, if it is of no use, you can post the exact problem here to be of more help. Good luck! |
Hello,
I tried overriding the Notification entity following your guide:
Unfortunately it's not working as it tries to create the table twice:
Looking at the output it's trying to execute the query twice. This is my config:
Thanks!
The text was updated successfully, but these errors were encountered: