Skip to content

Revision Comment

Tom Anderson edited this page Mar 17, 2016 · 3 revisions

To create a comment for a revision

$revisionComment = $serviceManager->get('ZF\Doctrine\Audit\Service\RevisionComment');

$revisionComment->setMessage('This is an example commit/audit message');
$targetObjectManager->flush();

There is a globally registered initializer if you'd rather use interface based dependency injection.

use ZF\Doctrine\Audit\Persistence;

class IndexController extends StandardAutoloader implements
    Persistence\RevisionCommentAwareInterface
    ...
{
    use Persistence\RevisionCommentAwareTrait;
    ...

    public function indexAction()
    {
        $this->getRevisionComment()->setComment('Change artist description');

        $artist = $this->getObjectManager()->getRepository('Db\Entity\Artist')->find(1);
        $artist->setDescription("rejuvenart");

        $this->getObjectManager()->flush();
    }
Clone this wiki locally