0

I would like to save notifications after certain events in my Symfony2 app. I've created a Notification Entity but I'm not sure how I can trigger an aftersave event on some other Entity to create a new Notification record.

In CakePHP I would add something like this to the other Model

function afterSave( )
{
    App::import( 'Model', 'Notification' );
    $Notification = new Notification;

    $notification = array( 'Notification' => array(
        'person_id' => Person::get( 'Person.id' ),
        'type' => 'foo',
        'title' => 'bar',
        'details' => 'lorem ipsum'
    ) );

    $Notification->save( $notification );
}
mike
  • 1,583
  • 1
  • 19
  • 35

1 Answers1

0

Definitely, take a look at Doctrine events - http://symfony.com/doc/current/cookbook/doctrine/event_listeners_subscribers.html

dmnptr
  • 4,258
  • 1
  • 20
  • 19