Skip to content

Commit

Permalink
Adds new event which is fired after the where clause processing has o…
Browse files Browse the repository at this point in the history
…ccurred, providing the QueryBuilder instance as the event target

- Allows for custom manipulation of the QueryBuilder after standard where clause processing, i.e. complex queries
  • Loading branch information
mgldev committed Feb 9, 2016
1 parent a706b2c commit f823f00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/ZucchiDoctrine/Query/Provider/DefaultOrm.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public function createQuery(ResourceEvent $event, $entityClass, $parameters)
$this->addLimit($queryBuilder, $limit);
}

// trigger event for manipulating $where
$providerEvent = new Event(Event::EVENT_QUERYBUILDER, $queryBuilder, array('entityClass' => $entityClass));
$providerEvent->setEntityManager($this->getObjectManager());
$this->getEventManager()->trigger($providerEvent);

return $queryBuilder;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ZucchiDoctrine/Query/Provider/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ class Event extends ZendEvent implements EntityManagerAwareInterface
const EVENT_WHERE = 'where';
const EVENT_ORDER = 'order';
const EVENT_LIMIT = 'limit';

const EVENT_QUERYBUILDER = 'querybuilder';
}

0 comments on commit f823f00

Please sign in to comment.