tenolo / doctrine-walker-bundle
This bundle add a event driven SQL output walker.
dev-master / 1.0.x-dev
2019-07-22 08:37 UTC
Requires
- php: ^7.2
- doctrine/common: ^2.6
- doctrine/dbal: ^2.5
- doctrine/doctrine-bundle: ^1.6
- doctrine/orm: ^2.5
- symfony/config: ^3.4|^4.0
- symfony/dependency-injection: ^3.4|^4.0
- symfony/doctrine-bridge: ^3.4|^4.0
- symfony/event-dispatcher: ^3.4|^4.0
- symfony/framework-bundle: ^3.4|^4.0
- symfony/http-kernel: ^3.4|^4.0
- symfony/yaml: ^3.4|^4.0
Requires (Dev)
- phpunit/phpunit: ^7.5
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2024-11-22 19:37:46 UTC
README
Doctrine Walker Bundle
A Symfony Bundle to add a event driven sql walker in Doctrine.
Install instructions
First you need to add tenolo/doctrine-walker-bundle
to composer.json
:
{ "require": { "tenolo/doctrine-walker-bundle": "~1.0" } }
or just do composer require tenolo/doctrine-walker-bundle
Please note that dev-master
latest development version.
Of course you can also use an explicit version number, e.g., 1.0.*
.
How to use
Just register some events.
<?php namespace Some\Namespace; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Tenolo\Bundle\DoctrineWalkerBundle\Event\SqlWalkerEvent; /** * Class ExampleWalkerListener */ class ExampleWalkerListener implements EventSubscriberInterface { /** * @inheritDoc */ public static function getSubscribedEvents() { return [ SqlWalkerEvent::FROM_CLAUSE => 'walkFromClause', ]; } /** * @param SqlWalkerEvent $event */ public function walkFromClause(SqlWalkerEvent $event): void { $sql = $event->getSql(); $em = $event->getEntityManager(); $conn = $event->getConnection(); $query = $event->getQuery(); // manipulate sql $sql = 'NONSENSE'; $event->setSql($sql); } }