/** * @param \Venne\Queue\Job $job * @param integer $priority */ public function run(Job $job, $priority) { /** @var Notification $notificationEntity */ $notificationEntity = $this->notificationRepository->find($job->arguments[0]); if ($notificationEntity === null) { return; } $qb = $this->notificationSettingRepository->createQueryBuilder('a')->andWhere('a.type IS NULL OR a.type = :type')->setParameter('type', $notificationEntity->type->id); if ($notificationEntity->user) { $qb = $qb->andWhere('a.targetUser IS NULL OR a.targetUser = :targetUser')->setParameter('targetUser', $notificationEntity->user->id); } if ($notificationEntity->target) { $qb = $qb->andWhere('a.target IS NULL OR a.target = :target')->setParameter('target', $notificationEntity->target); } if ($notificationEntity->targetKey) { $qb = $qb->andWhere('a.targetKey IS NULL OR a.targetKey = :targetKey')->setParameter('targetKey', $notificationEntity->targetKey); } $users = array(); foreach ($qb->getQuery()->getResult() as $setting) { $user = $setting->user !== null ? $setting->user : $notificationEntity->user; if (isset($users[$user->id]) && !$users[$user->id]['email']) { $users[$user->id]['email'] = $setting->email; } else { $users[$user->id] = array('user' => $user, 'email' => $setting->user !== null ? $setting->email : $notificationEntity->user->getEmail()); } } foreach ($users as $user) { $notificationUser = new NotificationUser($notificationEntity, $user['user']); $this->entityManager->persist($notificationUser); $this->entityManager->flush($notificationUser); if ($user['email']) { $this->jobManager->scheduleJob(new Job(EmailJob::getName(), null, array('user' => $user['user'] instanceof User ? $user['user']->id : $user['user'], 'notification' => $notificationUser->id)), $priority); } } }
public function find($id = null) { if (!$id) { $id = 0; } return $this->repository->find($id); }
public function render() { $this->template->job = $this->dataTransferManager->createQuery(JobDto::class, function () { return $this->jobRepository->find($this->id); })->enableCache()->fetch(); $this->template->render(); }
/** * @return \Venne\System\Components\AdminGrid\AdminGrid */ protected function createComponentTable() { $admin = $this->adminGridFactory->create($this->jobRepository); $table = $admin->getTable(); $table->addColumnText('type', 'Type')->getCellPrototype()->width = '35%'; $table->addColumnText('state', 'State')->getCellPrototype()->width = '15%'; $table->addColumnText('priority', 'Priority')->getCellPrototype()->width = '10%'; $table->addColumnDate('date', 'Date')->getCellPrototype()->width = '15%'; $table->addColumnDate('dateInterval', 'Interval')->getCellPrototype()->width = '15%'; $table->addColumnDate('round', 'Round')->getCellPrototype()->width = '10%'; // actions $table->addActionEvent('run', 'Run')->onClick[] = function ($id) { $job = $this->jobRepository->find($id); try { $this->jobManager->scheduleJob($job, JobManager::PRIORITY_REALTIME); $this->flashMessage($this->getTranslator()->translate('Job has been done.'), 'success'); } catch (JobFailedException $e) { $this->flashMessage($this->getTranslator()->translate('Job failed.'), 'warning'); } $this->redirect('this'); }; $table->addActionEvent('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $form = $admin->addForm('job', 'Job', function (Job $job = null) { return $this->jobFormService->getFormFactory($job !== null ? $job->getId() : null); }); $admin->connectFormWithAction($form, $table->getAction('edit')); $table->addActionEvent('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); return $admin; }
/** * @param \Venne\Queue\Job $job * @param integer $priority */ public function run(Job $job, $priority) { $user = $this->userRepository->find($job->arguments['user']); $notificationUser = $this->notificationUserRepository->find($job->arguments['notification']); $notification = $notificationUser->getNotification(); $this->emailManager->send($user->email, $user->name, NotificationEvent::getName(), 'userNotification', array('type' => $notification->type->type, 'action' => $notification->type->action, 'message' => $notification->type->message, 'user' => $notification->user, 'notification' => $notification, 'notificationManager' => $this)); }
/** * Vraci clanek podle Id (article_id) * @param int $id article_id pkey * @return object|null */ public function getById($id) { if (empty($id)) { return NULL; } return $this->myArticleRepository->find($id); }
public function getById($id) { $x = $this->repository->find($id); if ($x == NULL) { throw new RecordNotFoundException("Record with id {$id} not found!"); } return $x; }
/** * @param integer|null $primaryKey * @param integer|null $parentId * @return \Venne\Files\File */ protected function getEntity($primaryKey, $parentId = null) { $entity = parent::getEntity($primaryKey); if ($parentId !== null) { $entity->setParent($this->dirRepository->find($parentId)); } return $entity; }
public function render() { if ($this->id !== null) { $this->template->notification = $this->dataTransferManager->createQuery(NotificationDto::class, function () { return $this->notificationUserRepository->find($this->id); })->enableCache()->fetch(); } $this->template->render(); }
public function getText($ident) { if ($this->authorizator->canRead($ident)) { $et = $this->editableTextRepository->find($ident); if ($et === NULL) { return NULL; } else { return $et->getText(); } } else { throw new AuthenticationException("You have no authorization to get text"); } }
/** * Finds an entity by id. * @param mixed $id * @param int $lockMode * @param null $lockVersion * @return object * @throws IOException */ public function find($id, $lockMode = null, $lockVersion = null) { $result = parent::find($id, $lockMode, $lockVersion); if ($result === NULL) { throw new IOException('Not found', 404); } return $result; }
/** * @param AMQPMessage $message * @return bool */ public function process(AMQPMessage $message) { $ids = Json::decode((string) $message->body, Json::FORCE_ARRAY); /** @var Screenplay[] $documents */ $documents = []; foreach ($ids as $id) { /** @var Screenplay|NULL $screenplay */ $screenplay = $this->scenariosRepository->find($id); if ($screenplay === NULL) { $this->onError("Screenplay with ID #{$id} not found!"); return FALSE; } $documents[] = $this->createDocument($screenplay); } /** @var Index $indexEntity */ $indexEntity = $this->indicesRepository->findOneBy([], ['createdAt' => 'DESC']); $index = $this->client->getIndex($indexEntity->getName()); $type = $index->getType('screenplay'); $type->addDocuments($documents); return TRUE; }
/** * @return \Nette\Forms\Form */ protected function createComponentAccountForm() { $user = $this->userRepository->find($this->getUser()->getIdentity()->getId()); $formService = $this->securityManager->getUserTypeByClass($user->getClass())->getFrontFormService(); $form = $formService->getFormFactory($user->getId())->create(); $form->onSuccess[] = function () { $this->flashMessage($this->translator->translate('Account settings has been updated.'), 'success'); $this->redirect('this'); $this->redrawControl('content'); }; return $form; }
public function loadState(array $params) { if (isset($params['dirId'])) { $this->dir = $this->dirRepository->find($params['dirId']); } elseif ($this->root) { $this->dir = $this->root; } if (isset($params['fileId'])) { $this->file = $this->fileRepository->find($params['fileId']); $this->dir = $this->file->getParent(); } parent::loadState($params); }
/** * @param $tagID * @throws \Exception */ public function remove($tagID) { try { $this->em->beginTransaction(); /** @var Tag $tag */ $tag = $this->tagRepository->find($tagID); if ($tag === null) { $this->em->commit(); return; } $tagSearchUrl = $this->urlFacade->getUrl('Pages:Front:Search', 'tag', $tag->getId()); $this->em->remove($tag); $this->em->remove($tagSearchUrl); $this->em->flush(); $this->em->commit(); $this->onSuccessTagRemoval($tag, $tagID); } catch (\Exception $e) { $this->em->rollback(); $this->em->close(); throw $e; } }
/** * @param string $from * @param string $to * @param string $dropMode */ public function setFileParent($from, $to, $dropMode) { $fromType = substr($from, 0, 1); $from = substr($from, 2); $toType = substr($to, 0, 1); $to = substr($to, 2); $entity = $fromType == 'd' ? $this->dirRepository->find($from) : $this->fileRepository->find($from); $target = $toType == 'd' ? $this->dirRepository->find($to) : $this->fileRepository->find($to); if ($dropMode === 'before' || $dropMode === 'after') { $entity->setParent($target->parent); } else { $entity->setParent($target); } $this->entityManager->flush($entity); }
/** * @param integer $id * @param integer[] $action */ public function tableDelete($id, $action) { if (is_array($action)) { foreach ($action as $item) { $this->tableDelete($item, null); } } else { try { $this->repository->getEntityManager()->remove($this->repository->find($id)); $this->repository->getEntityManager()->flush(); } catch (\Exception $e) { $this->onError($this, $e); } } $this->redirect('this'); $this->redrawControl('table'); }
/** * @param string $songId * @return \string[] */ public function getSongPathAndName(string $songId) : array { /** @var Song $song */ $song = $this->songRepository->find($songId); return [$this->getSongPath($songId), $song->getName()]; }
/** * @param number $id * @return Entity\TaskGroup|null */ public function getById($id) { return $this->taskGroup->find($id); }
/** * @param $id * * @return null|Entity\Performance */ public function findPerformanceById($id) { return $this->performanceRepository->find($id); }
/** * @return \Kdyby\Doctrine\Entities\BaseEntity */ protected function createEntity() { $user = $this->userRepository->find($this->netteUser->getIdentity()->getId()); $class = new \ReflectionClass($this->getEntityClassName()); return $class->newInstanceArgs(array($user)); }
public function renderDefault() { $this->template->userDto = $this->dataTransferManager->createQuery(UserDto::class, function () { return $this->userRepository->find($this->getUser()->getIdentity()->getId()); })->enableCache(sprintf('#%s', $this->getUser()->getIdentity()->getId()))->fetch(); }
/** * Vraci tag podle Id (tag_id) * @param int $id tag_id pkey * @return object|null */ public function getById($id) { return $this->repository->find($id); }
/** * @param $id * * @return null|object */ public function findChildById($id) { return $this->childRepository->find($id); }
/** * @param int $urlId * @return Url|null */ public function getById($urlId) { return $this->urlRepository->find($urlId); }
/** * @param $id * @return null|Entity\Event */ public function findEventById($id) { return $this->eventRepository->find($id); }
public function getGenre(int $id) : Genre { return $this->genreRepository->find($id); }
/** * @return \Venne\Security\User|null */ private function getUser() { return $this->netteUser->isLoggedIn() ? $this->userRepository->find($this->netteUser->getIdentity()->getId()) : null; }
/** * @param $id * @return Season|NULL */ public function find($id) { return $this->seasonsRepository->find($id); }