/** * {@inheritdoc} */ public function find(ReadableCriteriaInterface $criteria) { // Ensure that object and resultset prototypes have been set $this->getObjectPrototype(); $event = $this->getEvent(); $event->setCriteria($criteria); $results = $this->getEventManager()->trigger(ModelEvent::EVENT_FIND_PRE, $event, function ($r) { return $r instanceof ResultSetInterface; }); if ($results->stopped()) { $last = $results->last(); if ($last instanceof ResultSetInterface) { $event->setResultSet($last); return $last; } } $event->setResultSet(parent::find($criteria)); $results = $this->getEventManager()->trigger(ModelEvent::EVENT_FIND_POST, $event, function ($r) { return $r instanceof ResultSetInterface; }); if ($results->stopped()) { $last = $results->last(); if ($last instanceof ResultSetInterface) { $event->setResultSet($last); } } return $event->getResultSet(); }