/** * Update * * @param GenericEvent $event * @return void */ public function update(GenericEvent $event) { $comment = $this->commentService->find($event['id']); $article = new \Article($comment->getLanguage()->getId(), $comment->getThread()->getNumber()); $authors = \ArticleAuthor::GetAuthorsByArticle($comment->getThread()->getNumber(), $comment->getLanguage()->getId()); $this->emailService->sendCommentNotification($comment, $article, $authors, $this->userService->getCurrentUser()); }
public function init() { $GLOBALS['controller'] = $this; $this->_helper->layout->disableLayout(); $this->service = $this->_helper->service('user'); $this->user = $this->service->getCurrentUser(); $this->_helper->contextSwitch()->addActionContext('update-topics', 'json')->initContext(); }
/** * Update audit * * @param GenericEvent $event * @return void */ public function update(GenericEvent $event) { list($resource, $action) = explode('.', $event->getName()); $user = isset($event['user']) ? $event['user'] : $this->userService->getCurrentUser(); $params = $event->getArguments(); $auditEvent = new AuditEvent(); $values = array('user' => $user, 'action' => $action, 'resource_id' => !empty($params['id']) ? $params['id'] : null, 'resource_type' => $resource, 'resource_diff' => !empty($params['diff']) ? $params['diff'] : null, 'resource_title' => !empty($params['title']) ? $params['title'] : null); $this->em->getRepository('Newscoop\\Entity\\AuditEvent')->save($auditEvent, $values); $this->em->flush(); }
/** * Update * * @param GenericEvent $event * * @return void */ public function update(GenericEvent $event) { $comment = $this->commentService->find($event['id']); $article = $this->em->getRepository('Newscoop\\Entity\\Article')->getArticle($comment->getThread(), $comment->getLanguage()->getId())->getSingleResult(); try { $user = $this->userService->getCurrentUser(); } catch (AuthenticationException $e) { $user = null; } $authors = \ArticleAuthor::GetAuthorsByArticle($comment->getThread(), $comment->getLanguage()->getId()); $this->emailService->sendCommentNotification($comment, $article, $authors, $user); }
public function testGetCurrentUserNotAuthorized() { $this->auth->expects($this->once())->method('hasIdentity')->will($this->returnValue(false)); $this->assertNull($this->service->getCurrentUser()); }