PHP code example of qimnet / update-tracker-bundle

1. Go to this page and download the library: Download qimnet/update-tracker-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/ */

    

qimnet / update-tracker-bundle example snippets



namespace ACME\MyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;

use Qimnet\UpdateTrackerBundle\Entity\UpdateTracker as BaseUpdateTracker;

/**
 * @ORM\Entity
 */
class UpdateTracker extends BaseUpdateTracker
{

}


namespace ACME\MyBundle\Controller;
class MyController
{
    public function myAction() 
    {
        $response = $this->get('qimnet.update_tracker.http_cached_response_factory')
            ->generate('my_namespace');
        if ($response->isNotModified($this->getRequest())) {
            return $response;
        }
        // Fetch content
        $response->setContent('Some content');
        return $response;
    }
}

namespace ACME\MyBundle\Controller;
class MyController
{
    /**
    *   Every variation of the output of this method should update the 
    *  "my_update_tracker" UpdateTracker.
    * 
    *   @Cache(expires="+1year")
    **/
    public function esiAction() {
        ...
        return $response;
    }
}


namespace ACME\MyBundle\Controller;
use Symfony\Component\HttpFoundation\Response;

class MyController
{
    public function myAction($id)
    {
        $content = $this->get('qimnet.update_tracker.cache_manager')
            ->getObject('my_namespace', 'my_object/' . $id, function(){
                //Fetch the content and return it
                return 'Some content';
            })
        return new Response($content);
    }
}