Comments (15)
Hi @khaliltr thanks for using the bundle :)
With Symfony 4 you have to specify services to use in your controller, the usage of the global container doesn't work anymore.
This might help you : https://symfony.com/doc/current/service_container.html
from notification-bundle.
I haven't understand, what i need to add in services.yml?
from notification-bundle.
Please i need help,
I have added this in controller
public function controllerFunction(Mgilet\NotificationBundle\Manager\NotificationManager $manager)
{
$notif = $manager->createNotification('New Test');
$notif->setMessage('Test');
$notif->setLink('http://symfony.com/');
$manager->addNotification(array($this->getUser()), $notif, true);
return $this->redirectToRoute('index');
}
But $notif is not added in database and in twig i see only the word "notifications" when i add {{ mgilet_notification_render(app.user) }}
from notification-bundle.
@khaliltr Have you updated your database schema ?
from notification-bundle.
yes i have notifiable_entity, notifiable_notification, and notification ,
I have added this in service.yaml
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
bind:
Mgilet\NotificationBundle\Manager\NotificationManager: '@mgilet.notification'
and
public function controllerFunction(Mgilet\NotificationBundle\Manager\NotificationManager $manager)
{
$notif = $manager->createNotification('New Test');
$notif->setMessage('Test');
$notif->setLink('http://symfony.com/');
$manager->addNotification(array($this->getUser()), $notif, true);
return $this->redirectToRoute('index');
}
the results : nothing in twig only the word "notifications" and nothing in database
from notification-bundle.
@khaliltr Did you add the @Notifiable
annotation to your user entity ?
from notification-bundle.
yes of course i have followed the documentation
@maximilienGilet THis what i have in entity
/**
* @ORM\Entity(repositoryClass="App\Repository\UtilisateurRepository")
* @ORM\Table(name="utilisateur")
* @Notifiable(name="Utilisateur")
*/
class Utilisateur implements UserInterface, \Serializable, AdvancedUserInterface, NotifiableInterface
from notification-bundle.
I think the probleme is in service, " . You should maybe alias this class to the existing "mgilet.notification" service."
from notification-bundle.
$manager->addNotification ( addNotification not work)
from notification-bundle.
I have added this alias in service
Mgilet\NotificationBundle\Manager\NotificationManager: '@mgilet.notification'
Now its work
But, @maximilienGilet how to see notifications like this GIF
from notification-bundle.
@khaliltr this was an example of implementation, it was made in the version 1 of the bundle.
You can find the old dropdown template in the old comits of the repository :
https://github.com/maximilienGilet/notification-bundle/blob/0133431f50b65778571e67541677e695c80ab987/Resources/views/notification_dropdown.html.twig
from notification-bundle.
from notification-bundle.
@khaliltr this is a sample based on the first version of the bundle, I don't think it works anymore with the current version. But you can use it as an example to implement with the current version of the bundle
from notification-bundle.
@maximilienGilet But how to loop through the notifications rendered in the twig helper?
from notification-bundle.
So, it took me some time to figure it out. You can access the variable notificationList
in the template that you have overridden and loop through it
from notification-bundle.
Related Issues (20)
- Seen at and type configs HOT 1
- How to display the notifications one by one in list HOT 3
- Security anyone? HOT 2
- mgilet_notification_render(app.user) gives me an error HOT 1
- make notification as seen on clik on it HOT 4
- Redirect users to a view rather than just returning JsonResponse(true)
- rendered notifications list contains no html HOT 2
- Missing config at installation : "Unknown Entity namespace" error. HOT 3
- Fix deprecation messages HOT 1
- How to use this in Symfony 4.4 HOT 3
- I need to understand how to listen these events with symfony 5 listener. HOT 3
- NotificationManager->removeNotification() does not remove notifications from Database HOT 1
- Hello HOT 3
- Conflict between Doctrine migration bundle and this bundle
- Notifications list contains no html HOT 4
- Upgrade / make compatible with Symfony 5.x HOT 2
- Problem with installed version of Twig 3.0 HOT 3
- Using Bundle
- configuration for "mgilet_notification" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notification-bundle.