PHP code example of priyank / doctrine-odm-audit

1. Go to this page and download the library: Download priyank/doctrine-odm-audit 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/ */

    

priyank / doctrine-odm-audit example snippets


class OdmEventManager implements IAuditHandler{
public function getPersistantRevisionObject(RevisionInfo $revisionInfo){
$revisionDoc = new RevisionDoc();
//Store revision info details into revision document
//Here you can store other details like action user infromatino in Revision document
return $revisionDoc;
}
public function getNamespaceOfDoctrineObject(){
return "Doctrine\Document";
}
public function isDeleteEventAuditEnabled()
    {
        return true;
    }

    public function isInsertEventAuditEnabled()
    {
        return true;
    }

    public function isRequireToStoreAudit($obj)
    {
        return ($obj instanceof UserDocument);
    }

    public function isUpdateEventAuditEnabled()
    {
        return true;
    }

    public function isUpsertEventAuditEnabled()
    {
        return true;
    }

$odmAuditEventManager = new OdmAuditEventManager(new OdmEventManager());
$eventManager               = new EventManager();
$eventManager->addEventListener([Events::onFlush], $odmAuditEventManager);