PHP code example of prezent / pulse-bundle

1. Go to this page and download the library: Download prezent/pulse-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

prezent / pulse-bundle example snippets


namespace AppBundle\Controller;

use Prezent\PulseBundle\Event\PulseEvent;
use Prezent\PulseBundle\Query\Query;
use Symfony\Bundle\FrameworkBundle\Controller\Controller

class AppController extends Controller
{
    public function trackableAction()
    {
        $this->get('event_dispatcher')->dispatch(PulseEvent::EVENT, new PulseEvent('some.action', [
            'user' => $this->getUser()->getId(),
        ]));
    }

    public function analyticsAction()
    {
        $query = new Query();
        $query
            ->setTypes(['some.action', 'other.action'])
            ->setStartDate(new \DateTime('-7 days'))
            ->setEndDate(new \DateTime())
        ;

        return $this->render('AppBundle:App:analytics.html.twig', [
            'result' => $this->get('prezent_pulse.repository')->query($query),
        ]);
    }
}