/** * Creates or retrieves a LastNotification entity by its event name. * * @param string $name Name of the event to retrive the record. */ private function getOrCreateByEventName($name) { $event = EventManager::getInstance()->getByName($name); $session = SessionManager::getCurrentSession(); $obj = PartKeepr::getEM()->getRepository('PartKeepr\\EventNotification\\LastNotification')->findOneBy(array('event' => $event->getId(), 'session' => $session->getId())); if (!$obj) { $obj = new LastNotification($event, $session); PartKeepr::getEM()->persist($obj); PartKeepr::getEM()->flush(); } return $obj; }
/** * This method is a callback for the PostPersist event. We will add it to our database * dependent eventNotification. * * @PostPersist @PostUpdate */ public function onPostPersist() { if (!$this->done) { EventManager::getInstance()->getOrCreateByName("Printing.pendingJob")->emit(); } }