/** * Remove a notification * * @param integer $id * * @return JsonResponse */ public function removeAction($id) { $user = $this->userContext->getUser(); if (null !== $user) { $this->manager->remove($user, $id); } return new JsonResponse(); }
/** * Return the number of unread notifications for the currently logged in user * * @return int */ public function countNotifications() { $user = $this->userContext->getUser(); if (null === $user) { return 0; } return $this->manager->countUnreadForUser($user); }
/** * Action for product sequential edition * @param Request $request * * @AclAncestor("pim_enrich_product_edit_attributes") * @return RedirectResponse */ public function sequentialEditAction(Request $request) { $sequentialEdit = $this->seqEditManager->createEntity($this->getObjects($request), $this->userContext->getUser()); if ($this->seqEditManager->findByUser($this->userContext->getUser())) { return new RedirectResponse($this->router->generate('pim_enrich_product_index', ['dataLocale' => $request->get('dataLocale')])); } $this->seqEditManager->save($sequentialEdit); return new RedirectResponse($this->router->generate('pim_enrich_product_edit', ['dataLocale' => $request->get('dataLocale'), 'id' => current($sequentialEdit->getObjectSet())])); }
/** * @param BuildAfter $event */ public function onBuildAfter(BuildAfter $event) { $defaults = $this->context->getUser()->getProductGridFilters(); if (empty($defaults)) { return; } $configuration = $event->getDatagrid()->getAcceptor()->getConfig(); foreach ($configuration['filters']['columns'] as $code => $filter) { if (in_array($code, $this->disallowed)) { continue; } $configuration->offsetSetByPath(sprintf('%s[%s][enabled]', Configuration::COLUMNS_PATH, $code), in_array($code, $defaults)); } }
/** * Get current scope from datagrid parameters, then user config * * @return string */ protected function getCurrentScopeCode() { $filterValues = $this->requestParams->get('_filter'); if (isset($filterValues['scope']['value']) && $filterValues['scope']['value'] !== null) { return $filterValues['scope']['value']; } else { $channel = $this->userContext->getUser()->getCatalogScope(); return $channel->getCode(); } }
/** * Remove a notification * * @param int $id * * @return JsonResponse */ public function removeAction($id) { $user = $this->userContext->getUser(); if (null !== $user) { $notification = $this->userNotifRepository->findOneBy(['id' => $id, 'user' => $user]); if ($notification) { $this->userNotifRemover->remove($notification); } } return new JsonResponse(); }
/** * Get current scope from datagrid parameters, then user config * * @return string */ protected function getCurrentScopeCode() { $filterValues = $this->requestParams->get('_filter'); $currentScopeCode = null; if (isset($filterValues['scope']['value'])) { $currentScopeCode = $filterValues['scope']['value']; } if (null === $currentScopeCode) { $requestFilters = $this->request->get('filters'); if (isset($requestFilters['scope']['value'])) { $currentScopeCode = $requestFilters['scope']['value']; } } if (null === $currentScopeCode) { $channel = $this->userContext->getUser()->getCatalogScope(); $currentScopeCode = $channel->getCode(); } return $currentScopeCode; }
/** * @param Request $request * * @return JsonResponse */ public function getAction(Request $request) { $sequentialEdit = $this->seqEditManager->findByUser($this->userContext->getUser()); return new JsonResponse($this->normalizer->normalize($sequentialEdit, 'internal_api')); }