Git Product home page Git Product logo

Comments (15)

maximilienGilet avatar maximilienGilet commented on September 24, 2024

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.

khaliltr avatar khaliltr commented on September 24, 2024

I haven't understand, what i need to add in services.yml?

from notification-bundle.

khaliltr avatar khaliltr commented on September 24, 2024

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.

maximilienGilet avatar maximilienGilet commented on September 24, 2024

@khaliltr Have you updated your database schema ?

from notification-bundle.

khaliltr avatar khaliltr commented on September 24, 2024

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.

maximilienGilet avatar maximilienGilet commented on September 24, 2024

@khaliltr Did you add the @Notifiable annotation to your user entity ?

from notification-bundle.

khaliltr avatar khaliltr commented on September 24, 2024

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.

khaliltr avatar khaliltr commented on September 24, 2024

I think the probleme is in service, " . You should maybe alias this class to the existing "mgilet.notification" service."

from notification-bundle.

khaliltr avatar khaliltr commented on September 24, 2024

$manager->addNotification ( addNotification not work)

from notification-bundle.

khaliltr avatar khaliltr commented on September 24, 2024

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

https://camo.githubusercontent.com/aa3ef4e798bf4d2ac1aca1e6fa048f2ea40f6360/687474703a2f2f692e696d6775722e636f6d2f30374f634636632e676966

from notification-bundle.

maximilienGilet avatar maximilienGilet commented on September 24, 2024

@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.

khaliltr avatar khaliltr commented on September 24, 2024

from notification-bundle.

maximilienGilet avatar maximilienGilet commented on September 24, 2024

@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.

aquibbaig avatar aquibbaig commented on September 24, 2024

@maximilienGilet But how to loop through the notifications rendered in the twig helper?

from notification-bundle.

aquibbaig avatar aquibbaig commented on September 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.