baskin/history-bundle

Twig Extension for Gedmo Loggable

Installs: 2 788

Dependents: 2

Suggesters: 0

Security: 0

Stars: 5

Watchers: 1

Forks: 1

Open Issues: 2

Type:symfony-bundle

v2.0.1 2016-05-23 21:16 UTC

This package is not auto-updated.

Last update: 2021-11-27 03:23:07 UTC


README

SensioLabsInsight

knpbundles.com

Twig Extension for DoctrineExtensions Loggable. StofDoctrineExtensionsBundle allows to easily use DoctrineExtensions in your Symfony project by configuring it through a ListenerManager and the DIC.

Setting up the bundle

Add BaskinHistoryBundle to your project

composer require baskin/history-bundle

Enable the Bundle

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Baskin\HistoryBundle\BaskinHistoryBundle(),
    );
}

Configuration Reference

Below is the full default configuration for the bundle:

# app/config/config.yml
baskin_history:
  revert: false # change if you want to revert function
  versionParameter: version # Query parameter for revert function ex: /route?version=12
  template: BaskinHistoryBundle:History:history.html.twig #history log template

The reference can be dumped using the following command: php app/console config:dump-reference BaskinHistoryBundle

Usage

Simple twig function with your loggable entity parameter.

{{ getLogs(entity) }}

Revert Function Usage

Firstly revert configuration must be enabled. And use reverter service revert method on controller method.`

$entity = $em->getRepository('AppBundle:YourEntity')->find($id);

$this->get('reverter')->revert($entity);  

Usage with SensioFrameworkExtraBundle ParamConverter

Basically it is automatically convert your entity. If you want to disable you must set revertable options to false.

/**
 * @ParamConverter("yourEntity", options={"revertable" = false})
 */
public function showAction(YourEntity $yourEntity)
{
    ...
}  

Note : If you don't want to show Show this version button set second parameter false {{ getLogs(entity, false) }}