/** * @return \Venne\System\Components\AdminGrid\AdminGrid */ protected function createComponentTable() { $qb = $this->notificationSettingRepository->createQueryBuilder('a')->andWhere('a.user = :user')->setParameter('user', $this->presenter->user->identity->getId()); $admin = $this->adminGridFactory->create($this->notificationSettingRepository); $table = $admin->getTable(); $table->setTranslator($this->translator); $table->setModel(new Doctrine($qb)); // columns $table->addColumnText('user', 'User')->getCellPrototype()->width = '15%'; $table->addColumnText('type', 'Type')->setSortable()->setCustomRender(function (NotificationSetting $entity) { return $entity->type !== null ? $this->notificationManager->getType($entity->type->type)->getHumanName() : ''; })->getCellPrototype()->width = '20%'; $table->addColumnText('action', 'Action')->setCustomRender(function (NotificationSetting $entity) { return $entity->type !== null ? $entity->type->action : ''; })->getCellPrototype()->width = '15%'; $table->addColumnText('target', 'Target')->getCellPrototype()->width = '20%'; $table->addColumnText('targetKey', 'Target key')->getCellPrototype()->width = '10%'; $table->addColumnText('targetUser', 'Target user')->getCellPrototype()->width = '20%'; // actions $event = $table->addActionEvent('edit', 'Edit'); $event->getElementPrototype()->class[] = 'ajax'; $form = $admin->addForm('notification', 'Notification setting', function (NotificationSetting $notificationSetting = null) { return $this->notificationSettingFormService->getFormFactory($notificationSetting !== null ? $notificationSetting->getId() : null); }); $admin->connectFormWithAction($form, $event); // Toolbar $toolbar = $admin->getNavbar(); $section = $toolbar->addSection('new', 'Create', 'file'); $admin->connectFormWithNavbar($form, $section); $deleteEvent = $table->addActionEvent('delete', 'Delete'); $deleteEvent->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($deleteEvent); return $admin; }
/** * @param \Venne\Security\User $entity * @param \Doctrine\ORM\Event\LifecycleEventArgs $event */ public function postPersist(User $entity, LifecycleEventArgs $event) { if (!self::$lock) { self::$lock = true; $this->notificationManager->notify(RegistrationEvent::getName(), $entity, 'registration', 'User has been registered.', $entity); self::$lock = false; } }
public function render() { $this->template->notifications = $this->dataTransferManager->createQuery(NotificationDto::class, function () { return $this->notificationManager->getNotifications(5, $this->offset); })->enableCache($this->offset)->fetchAll(); $this->template->notificationCount = $this->notificationManager->countNotifications(); $this->template->offset = $this->offset + 5; $this->template->render(); }
public function postPersist(Invitation $entity, LifecycleEventArgs $event) { if (!self::$lock) { self::$lock = true; $this->emailManager->send($entity->email, null, InvitationEvent::getName(), 'invitation', array('link' => $this->application->presenter->link('//:Admin:System:Login:default', array('registration' => $entity->registration->id, 'hash' => $entity->hash)))); $this->notificationManager->notify(InvitationEvent::getName(), $entity, 'invitation', 'User has been invited.'); self::$lock = false; } }
/** * @param \Venne\Security\User $user * @param string $link * @param \Venne\Security\User|null $sendBy */ public function sendRecoveryUrl(User $user, $link, User $sendBy = null) { $sendBy = $sendBy !== null ? $sendBy : $user; $this->emailManager->send($user->getEmail(), null, PasswordRecoveryEvent::getName(), 'passwordRecovery', array('link' => $link)); $this->notificationManager->notify(PasswordRecoveryEvent::getName(), $user, 'passwordRecovery', 'Password recovery URL has been sent.', $sendBy); }
/** * @return \Kdyby\Doctrine\EntityRepository */ private function getUserRepository() { $entityManager = $this->container->getByType(\Doctrine\ORM\EntityManager::class); return $entityManager->getRepository(User::class); }