Symfony2 onAuthenticationSuccess handler and Doctrine2 exception-Collection of common programming errors

All! Could someone help me with Symfony2 question? I’d like to save into the database all the events (request related data) regarding user login [success, failure] and logout [success]. Implementation and exception below.

Here is the config.yml

services:

login_success_handler:
    class:  Boomster\LibraryBundle\Handler\LoginSuccessHandler
    arguments:  [@security.context, @doctrine]

login_failure_handler:
    class:  Boomster\LibraryBundle\Handler\LoginFailureHandler
    arguments:  [@security.context, @doctrine]

logout_success_handler:
    class:  Boomster\LibraryBundle\Handler\LogoutSuccessHandler
    arguments:  [@security.context, @doctrine]

Here is firewall security.yml

firewalls:
    secured_area:
        pattern: ^/.*
        form_login:
            check_path: auth_check
            login_path: auth_login
            success_handler: login_success_handler
            failure_handler: login_failure_handler
        logout:
            path:   auth_logout
            target: site_index
            success_handler: logout_success_handler
        anonymous: ~

Here is LoginSuccessHandler handler:

Originally posted 2013-11-27 05:07:24.