Ejemplo n.º 1
0
 /**
  * @param Url $url
  * @return Url|object
  * @throws \Doctrine\DBAL\ConnectionException
  * @throws \Exception
  */
 public function encode(Url $url)
 {
     $this->em->beginTransaction();
     try {
         $urlRepository = $this->em->getRepository('Rz\\Bundle\\UrlShortenerBundle\\Entity\\Url');
         $entity = $urlRepository->findOneBy(['url' => $url->getUrl()]);
         if ($entity) {
             /** @var Url $url */
             $url = $entity;
         } else {
             $url->setNew(true);
             $this->em->persist($url);
             $this->em->flush();
             $url->setCode($this->encoder->encode($url->getId()));
             $params = ['code' => $url->getCode()];
             if (!$url->isDefaultSequence()) {
                 $params['index'] = $url->getSequence();
             }
             $url->setShortUrl($this->router->generate(UrlShortenerBundle::URL_GO, $params, UrlGeneratorInterface::ABSOLUTE_URL));
             $this->em->persist($url);
             $this->em->flush();
         }
         $this->em->getConnection()->commit();
         return $url;
     } catch (\Exception $e) {
         $this->em->getConnection()->rollBack();
         throw $e;
     }
 }
Ejemplo n.º 2
0
 public function serializeRouteArrayToJson(JsonSerializationVisitor $visitor, array $route, array $type, Context $context)
 {
     if (is_array($route)) {
         list($routeName, $routeParameters) = $route;
         return $this->router->generate($routeName, $routeParameters);
     }
 }
Ejemplo n.º 3
0
 /**
  * @param string $route
  * @param array  $data
  *
  * @return RedirectResponse
  */
 public function redirectToRoute($route, array $data = array())
 {
     if ('referer' === $route) {
         return $this->redirectToReferer();
     }
     return $this->redirect($this->router->generate($route, $data));
 }
 public function onKernelController(FilterControllerEvent $event)
 {
     $controller = $event->getController();
     if (!is_array($controller)) {
         return;
     }
     $session = $event->getRequest()->getSession();
     /** @var BaseController $ctrl */
     $ctrl = $controller[0];
     if (!is_object($ctrl) || !$ctrl instanceof BaseController) {
         return;
     }
     // no loop for you, also allow username checking
     if ($ctrl instanceof ProfileController && ($controller[1] == 'updateUsernameAction' || $controller[1] == 'checkUsernameAction')) {
         return;
     }
     /** @var User $user */
     $user = $ctrl->getUser();
     if ($user && $this->isGUID($user->getUsername())) {
         $session->getFlashBag()->add('error', "We recently changed our username restrictions. Your previous username is no longer valid. Please create a new one.");
         $url = $this->router->generate('reset_username');
         $event->setController(function () use($url) {
             return new RedirectResponse($url);
         });
     }
 }
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $request = $event->getRequest();
     $routes = $this->router->getRouteCollection();
     $route = $routes->get($request->attributes->get('_route'));
     if (!$route->getOption('requires_license')) {
         return;
     }
     if ('active' != $request->get('lic') && $this->kernel->getEnvironment() == 'prod') {
         // Checking for whitelisted users
         try {
             $user = $this->tokenStorage->getToken()->getUser();
             $today = date('Y-m-d');
             if ($user instanceof UserInterface) {
                 $whitelist = $this->kernel->getContainer()->getParameter('license_whitelist');
                 foreach ($whitelist as $allowed) {
                     if ($allowed['client_key'] == $user->getClientKey() && $today <= $allowed['valid_till']) {
                         return;
                     }
                 }
             }
         } catch (\Exception $e) {
             // Do nothing
         }
         $url = $this->router->generate('atlassian_connect_unlicensed');
         $response = new RedirectResponse($url);
         $event->setResponse($response);
     }
 }
Ejemplo n.º 6
0
 /**
  * Creates a Response object to send upon a successful logout.
  *
  * @param Request $request
  *
  * @return Response never null
  */
 public function onLogoutSuccess(Request $request)
 {
     if ($request->isXmlHttpRequest() or 'json' == $request->getRequestFormat()) {
         return new JsonResponse(true);
     }
     return new RedirectResponse($this->router->generate('homepage'));
 }
Ejemplo n.º 7
0
 public function createCollection(QueryBuilder $qb, Request $request, $route, array $routeParams = array())
 {
     $page = $request->query->get(self::PARAMETER_NAME_PAGE_NUMBER, 1);
     $count = $request->query->get(self::PARAMETER_NAME_PAGE_SIZE, self::PAGE_DEFAULT_COUNT);
     if ($count > self::MAX_PAGE_COUNT) {
         $count = self::MAX_PAGE_COUNT;
     }
     if ($count <= 0) {
         $count = self::PAGE_DEFAULT_COUNT;
     }
     $adapter = new DoctrineORMAdapter($qb);
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage($count);
     $pagerfanta->setCurrentPage($page);
     $players = [];
     foreach ($pagerfanta->getCurrentPageResults() as $result) {
         $players[] = $result;
     }
     $paginatedCollection = new PaginatedCollection($players, $pagerfanta->getNbResults());
     // make sure query parameters are included in pagination links
     $routeParams = array_merge($routeParams, $request->query->all());
     $createLinkUrl = function ($targetPage) use($route, $routeParams) {
         return $this->router->generate($route, array_merge($routeParams, array(self::PARAMETER_NAME_PAGE_NUMBER => $targetPage)));
     };
     $paginatedCollection->addLink('self', $createLinkUrl($page));
     $paginatedCollection->addLink('first', $createLinkUrl(1));
     $paginatedCollection->addLink('last', $createLinkUrl($pagerfanta->getNbPages()));
     if ($pagerfanta->hasNextPage()) {
         $paginatedCollection->addLink('next', $createLinkUrl($pagerfanta->getNextPage()));
     }
     if ($pagerfanta->hasPreviousPage()) {
         $paginatedCollection->addLink('prev', $createLinkUrl($pagerfanta->getPreviousPage()));
     }
     return $paginatedCollection;
 }
Ejemplo n.º 8
0
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  * @throws \Exception
  */
 public function __invoke(Request $request)
 {
     $user = $this->getUser();
     if (!$user) {
         throw $this->createAccessDeniedException();
     }
     $createWalletCommand = $this->createCreateWalletCommand();
     $createWalletForm = $this->walletFormFactory->createCreateForm($createWalletCommand);
     $createWalletForm->handleRequest($request);
     if (!$createWalletForm->isValid()) {
         $validationMsg = $this->getAllFormErrorMessagesAsString($createWalletForm);
         $this->addFlash('error', $this->trans('create_transaction_form.flash.invalid_form') . ' ' . $validationMsg);
     } else {
         /** @var CreateWalletCommand $createWalletCommand */
         $createWalletCommand = $createWalletForm->getData();
         $createWalletCommand->setWalletOwnerId($user->getId()->getValue());
         $createWalletCommand->setToken($user->getBlockCypherToken());
         try {
             $commandValidator = new CreateWalletCommandValidator();
             $commandValidator->validate($createWalletCommand);
             $this->commandBus->handle($createWalletCommand);
             $this->addFlash('success', $this->trans('wallet.flash.create_successfully'));
             $url = $this->router->generate('bc_app_wallet_wallet.index');
             return new RedirectResponse($url);
         } catch (\Exception $e) {
             $this->addFlash('error', $e->getMessage());
         }
     }
     return $this->renderWalletShowNew($request, $createWalletForm->createView());
 }
Ejemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     $data = $view->parent->vars['value'];
     if (is_object($data)) {
         $view->vars['grid_url'] = $this->router->generate('oro_entity_relation', ['id' => $data->getId() ? $data->getId() : 0, 'entityName' => str_replace('\\', '_', get_class($data)), 'fieldName' => $form->getName()]);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function generateForOrderCheckoutState(OrderInterface $order, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
 {
     if (!isset($this->routeCollection[$order->getCheckoutState()]['route'])) {
         throw new RouteNotFoundException();
     }
     return $this->router->generate($this->routeCollection[$order->getCheckoutState()]['route'], $parameters, $referenceType);
 }
Ejemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function generateUrl(StoredFile $storedFile)
 {
     $storageKey = $storedFile->getStorageKey();
     $storageKey .= '/' . $storedFile->getRepository()->getName();
     $storageKey .= '/' . $storedFile->getFilename();
     return $this->router->generate($this->routeName, array('storageKey' => $storageKey), RouterInterface::NETWORK_PATH);
 }
 /**
  * @throws InvalidConfigurationException
  */
 public function configureTabMenu(AdminInterface $admin, MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
 {
     if (!($subject = $admin->getSubject())) {
         return;
     }
     if (!$subject instanceof RouteReferrersReadInterface && !$subject instanceof Route) {
         throw new InvalidConfigurationException(sprintf('%s can only be used on subjects which implement Symfony\\Cmf\\Component\\Routing\\RouteReferrersReadInterface or Symfony\\Component\\Routing\\Route.', __CLASS__));
     }
     if ($subject instanceof PrefixInterface && !is_string($subject->getId())) {
         // we have an unpersisted dynamic route
         return;
     }
     $defaults = array();
     if ($subject instanceof TranslatableInterface) {
         if ($locale = $subject->getLocale()) {
             $defaults['_locale'] = $locale;
         }
     }
     try {
         $uri = $this->router->generate($subject, $defaults);
     } catch (RoutingExceptionInterface $e) {
         // we have no valid route
         return;
     }
     $menu->addChild($this->translator->trans('admin.menu_frontend_link_caption', array(), 'CmfRoutingBundle'), array('uri' => $uri, 'attributes' => array('class' => 'sonata-admin-menu-item', 'role' => 'menuitem'), 'linkAttributes' => array('class' => 'sonata-admin-frontend-link', 'role' => 'button', 'target' => '_blank', 'title' => $this->translator->trans('admin.menu_frontend_link_title', array(), 'CmfRoutingBundle'))));
 }
Ejemplo n.º 13
0
 /**
  * @param HitEvent $event
  */
 public function onHit(HitEvent $event)
 {
     if ($event->getMetadata()->reflection->getName() !== 'Sulu\\Bundle\\EventBundle\\Entity\\Event') {
         return;
     }
     $locale = $this->requestAnalyzer->getCurrentLocalization()->getLocalization();
     $document = $event->getHit()->getDocument();
     $eventApiEntity = $this->eventManager->findByIdAndLocale($document->getId(), $locale);
     if (!$eventApiEntity) {
         return;
     }
     $startDate = $eventApiEntity->getStartDate();
     $endDate = $eventApiEntity->getEndDate();
     $categories = $eventApiEntity->getCategories();
     $categoryTitles = array();
     foreach ($categories as $category) {
         $categoryTitles[] = $category->getName();
     }
     $startDateField = new Field('start_date', $startDate->format('c'), Field::TYPE_STRING);
     $document->addField($startDateField);
     if ($endDate) {
         $endDateField = new Field('end_date', $endDate->format('c'), Field::TYPE_STRING);
         $document->addField($endDateField);
     }
     $categoryTitleField = new Field('category_title', implode(', ', $categoryTitles), Field::TYPE_STRING);
     $document->addField($categoryTitleField);
     $url = $this->router->generate('sulu_events.detail', array('id' => $eventApiEntity->getId(), 'slug' => $eventApiEntity->getSlug()));
     $document->setUrl($url);
 }
 /**
  * @param array $items
  * @param $shippingDetails
  * @param string $intent
  * @throws Exception
  * @return null|string
  */
 public function createPayment(array $items, Details $shippingDetails, $intent = PaymentConst::INTENT_SALE)
 {
     $apiContext = $this->connectionService->getApiContext();
     $dispatcher = $this->connectionService->getDispatcher();
     $dispatcher->dispatch(PaymentEvent::NEW_SETUP);
     $successUrl = '';
     $cancelUrl = '';
     switch ($intent) {
         case PaymentConst::INTENT_SALE:
             $successUrl = $this->router->generate('paypal_payment_sale_success', array(), true);
             $cancelUrl = $this->router->generate('paypal_payment_sale_cancel', array(), true);
             break;
         case PaymentConst::INTENT_AUTHORIZE:
             $successUrl = $this->router->generate('paypal_payment_authorize_success', array(), true);
             $cancelUrl = $this->router->generate('paypal_payment_authorize_cancel', array(), true);
             break;
     }
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($successUrl)->setCancelUrl($cancelUrl);
     $payment = PaymentService::create($items, $shippingDetails, $intent, PaymentConst::METHOD_PAYPAL);
     $payment->setRedirectUrls($redirectUrls);
     $paymentEvent = new PayPalPaymentEvent($payment);
     $dispatcher->dispatch(PaymentEvent::NEW_START, $paymentEvent);
     $result = $payment->create($apiContext);
     $paymentEvent = new PayPalPaymentEvent($result);
     $dispatcher->dispatch(PaymentEvent::NEW_END, $paymentEvent);
     $payment->create($apiContext);
     $approvalUrl = $payment->getApprovalLink();
     return $approvalUrl;
 }
Ejemplo n.º 15
0
 public function onMainTopMenuTools(HookRenderBlockEvent $event)
 {
     $isGranted = $this->securityContext->isGranted(["ADMIN"], [], [BoSearch::getModuleCode()], [AccessManager::VIEW]);
     if ($isGranted) {
         $event->add(['title' => $this->trans('Search product', [], BoSearch::DOMAIN_NAME), 'url' => $this->router->generate('bosearch.product.view')]);
     }
 }
Ejemplo n.º 16
0
 /**
  * @param \Twig_Environment $environment
  * @param $node
  * @param array $options
  * @return string
  */
 public function renderMenuItemTemplate(\Twig_Environment $environment, $node, $options = array())
 {
     $template = isset($options['template']) ? $options['template'] : false;
     if ($template === false) {
         $template = 'KunstmaanMenuBundle::menu-item.html.twig';
     }
     $active = false;
     if ($node['type'] == MenuItem::TYPE_PAGE_LINK) {
         $url = $this->router->generate('_slug', array('url' => $node['nodeTranslation']['url']));
         if ($this->router->getContext()->getPathInfo() == $url) {
             $active = true;
         }
     } else {
         $url = $node['url'];
     }
     if ($node['type'] == MenuItem::TYPE_PAGE_LINK) {
         if ($node['title']) {
             $title = $node['title'];
         } else {
             $title = $node['nodeTranslation']['title'];
         }
     } else {
         $title = $node['title'];
     }
     return $environment->render($template, array('menuItem' => $node, 'url' => $url, 'options' => $options, 'title' => $title, 'active' => $active));
 }
Ejemplo n.º 17
0
 /**
  * @param Request $request
  * @return Response
  * @throws \Exception
  */
 public function __invoke(Request $request)
 {
     $walletId = $request->get('walletId');
     $walletDto = $this->walletServiceFacade->getWallet($walletId);
     $this->checkAuthorizationForWallet($walletDto);
     $createTransactionCommand = $this->createCreateTransactionCommand($walletId);
     $user = $this->getUser();
     $createTransactionForm = $this->transactionFormFactory->createCreateForm($createTransactionCommand, $user->getId()->getValue());
     $createTransactionForm->handleRequest($request);
     if (!$createTransactionForm->isValid()) {
         $validationMsg = $this->getAllFormErrorMessagesAsString($createTransactionForm);
         $this->addFlash('error', $this->trans('create_transaction_form.flash.invalid_form') . ' ' . $validationMsg);
     } else {
         /** @var CreateTransactionCommand $createTransactionCommand */
         $createTransactionCommand = $createTransactionForm->getData();
         try {
             $commandValidator = new CreateTransactionCommandValidator();
             $commandValidator->validate($createTransactionCommand);
             $this->commandBus->handle($createTransactionCommand);
             $this->addFlash('success', $this->trans('transaction.flash.create_successfully'));
             $url = $this->router->generate('bc_app_wallet_transaction.index', array('walletId' => $createTransactionCommand->getWalletId()));
             return new RedirectResponse($url);
         } catch (\Exception $e) {
             $this->addFlash('error', $e->getMessage());
         }
     }
     $walletDto = $this->walletServiceFacade->getWallet($walletId);
     return $this->renderTransactionShowNew($request, $createTransactionForm->createView(), $walletDto);
 }
Ejemplo n.º 18
0
 /**
  * @param array $urlParameters
  *
  * @return string
  */
 protected function getUrl(array $urlParameters = array())
 {
     if (null === $this->getRouteName()) {
         throw new \RuntimeException('You need to provide route name, null given');
     }
     return $this->router->generate($this->getRouteName(), $urlParameters, true);
 }
Ejemplo n.º 19
0
 /**
  * @param array $workshops
  * @return array
  */
 public function decorate(array $workshops = [])
 {
     $workshops = array_map(function (Workshop $workshop) {
         return ["id" => $workshop->getSlug(), "start" => $workshop->getStartDate()->format(DateTime::ISO8601), "end" => $workshop->getEndDate()->format(DateTime::ISO8601), "title" => sprintf("%s: %s", $workshop->getCity(), $workshop->getTitle()), "editable" => false, "backgroundColor" => '', "url" => $this->router->generate("evento_show", ["slug" => $workshop->getSlug()])];
     }, $workshops);
     return $workshops;
 }
 /**
  * Sends the Hydra header on each response.
  *
  * @param FilterResponseEvent $event
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $event->getResponse()->headers->set('Link', sprintf('<%s>; rel="%sapiDocumentation"', $this->router->generate('api_hydra_vocab', [], UrlGeneratorInterface::ABSOLUTE_URL), ContextBuilder::HYDRA_NS));
 }
 public function onPostSerialize(ObjectEvent $event)
 {
     /**
      * @var JsonSerializationVisitor $visitor
      */
     $visitor = $event->getVisitor();
     $object = $event->getObject();
     $annotations = $this->annotationReader->getClassAnnotations(new \ReflectionObject($object));
     $links = array();
     foreach ($annotations as $annotation) {
         if ($annotation instanceof Link) {
             if ($annotation->url) {
                 $uri = $this->evaluate($annotation->url, $object);
             } else {
                 $uri = $this->router->generate($annotation->route, $this->resolveParams($annotation->params, $object));
             }
             // allow a blank URI to be an optional link
             if ($uri) {
                 $links[$annotation->name] = $uri;
             }
         }
     }
     if ($links) {
         $visitor->addData('_links', $links);
     }
 }
Ejemplo n.º 22
0
 public function lostPasswordMail(User $user)
 {
     $template = 'HomefinanceBundle:mailer:lost_password.txt.twig';
     $url = $this->router->generate('reset_password_check_token', array('token' => $user->getConfirmationToken()), true);
     $context = array('user' => $user, 'confirmationUrl' => $url);
     $this->sendMessage($template, $context, $user->getEmail());
 }
Ejemplo n.º 23
0
 /**
  * @param array $lessons
  * @return array
  */
 public function decorate(array $lessons = [])
 {
     $lessons = array_map(function (Lesson $lesson) {
         return ["id" => sprintf("%s#%s", $lesson->getWorkshop()->getSlug(), $lesson->getId()), "start" => $lesson->getStartDate()->format("Y-m-d H:i:s"), "end" => $lesson->getEndDate()->format("Y-m-d H:i:s"), "editable" => false, "url" => sprintf("%s#%s", $this->router->generate("evento_show", ["slug" => $lesson->getWorkshop()->getSlug()]), $lesson->getId())];
     }, $lessons);
     return $lessons;
 }
Ejemplo n.º 24
0
 /**
  * Intercept Exceptions and send valid ajax errors
  * The idea is to NOT send HTML response when an issue(i.e.session expired) is encountered
  * in an ajax request.
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     // Get the exception object from the received event
     $exception = $event->getException();
     $request = $event->getRequest();
     $isAjaxRequest = $request->isXmlHttpRequest();
     if ($isAjaxRequest) {
         $headers = [];
         // handle session expired
         if ($exception instanceof AuthenticationException) {
             $loginUrl = $this->router->generate('fos_user_security_login');
             // add custom header to redirect to login page on the client
             $headers['relogin'] = true;
             $headers['login-url'] = $loginUrl;
             $response = new Response('Authentication Required', 200, $headers);
         } elseif ($exception instanceof AccessDeniedException) {
             $headers['not-authorized'] = true;
             $response = new Response('Not authorized', 403, $headers);
         } else {
             $responseData = ['status' => false, 'msg' => 'Unknown Issue Encountered', 'data' => ['exception' => ['message' => $exception->getMessage(), 'file' => "{$exception->getFile()}:{$exception->getLine()}", 'trace' => $exception->getTraceAsString()]]];
             $response = new Response(json_encode($responseData), 500, $headers);
         }
         $event->setResponse($response);
         $event->stopPropagation();
     }
 }
 /**
  * {@inheritDoc}
  */
 public function sendResettingEmailMessage(UserInterface $user)
 {
     $template = $this->parameters['resetting_password.template'];
     $url = $this->router->generate('fos_user_resetting_reset', array('token' => $user->getConfirmationToken()), true);
     $rendered = $this->templating->render($template, array('confirmationUrl' => $url, 'user' => $user));
     $this->sendEmailMessage($rendered, $user->getEmail());
 }
 /**
  * @param BreadcrumbItem $item
  * @param array          $variables
  * @return ProcessedBreadcrumbItem
  */
 public function process(BreadcrumbItem $item, $variables)
 {
     // Process the label
     if ($item->getLabel()[0] === '$') {
         $processedLabel = $this->parseValue($item->getLabel(), $variables);
     } else {
         $processedLabel = $this->translator->trans($item->getLabel());
     }
     // Process the route
     // TODO: cache parameters extracted from current request
     $params = [];
     foreach ($this->requestStack->getCurrentRequest()->attributes as $key => $value) {
         if ($key[0] !== '_') {
             $params[$key] = $value;
         }
     }
     foreach ($item->getRouteParams() ?: [] as $key => $value) {
         if ($value[0] === '$') {
             $params[$key] = $this->parseValue($value, $variables);
         } else {
             $params[$key] = $value;
         }
     }
     if ($item->getRoute() !== null) {
         $processedUrl = $this->router->generate($item->getRoute(), $params);
     } else {
         $processedUrl = null;
     }
     return new ProcessedBreadcrumbItem($processedLabel, $processedUrl);
 }
Ejemplo n.º 27
0
 /**
  * {@inheritdoc}
  */
 public function redirectToRoute(RequestConfiguration $configuration, $route, array $parameters = [])
 {
     if ('referer' === $route) {
         return $this->redirectToReferer($configuration);
     }
     return $this->redirect($configuration, $this->router->generate($route, $parameters));
 }
Ejemplo n.º 28
0
 /**
  * {@inheritdoc}
  */
 protected function getUriFromNode(NodeInterface $node)
 {
     if ($node instanceof RouterNodeInterface && null !== $node->getRoute()) {
         return $this->router->generate($node->getRoute(), $node->getRouteParameters(), $node->isRouteAbsolute());
     }
     return $node->getUri();
 }
Ejemplo n.º 29
0
 /**
  * return the URL from extref
  *
  * @param ExtReference $extReference Extref
  * @return string
  * @throws \InvalidArgumentException
  */
 public function getUrl(ExtReference $extReference)
 {
     if (!isset($this->mapping[$extReference->getRef()])) {
         throw new \InvalidArgumentException(sprintf('Could not create URL from extref "%s"', json_encode($extReference)));
     }
     return $this->router->generate($this->mapping[$extReference->getRef()] . '.get', ['id' => $extReference->getId()], true);
 }
Ejemplo n.º 30
0
 /**
  * @inheritdoc
  */
 public function populateSitemap(SitemapPopulateEvent $event)
 {
     $event->getGenerator()->addUrl(new UrlConcrete($this->router->generate('harentius_blog_homepage', [], true), $this->homepage->getUpdatedAt(), UrlConcrete::CHANGEFREQ_WEEKLY, 1.0), 'pages');
     // Pages
     $pages = $this->pageRepository->findPublishedNotSlugOrdered($this->homepageSlug);
     foreach ($pages as $page) {
         $event->getGenerator()->addUrl(new UrlConcrete($this->router->generate('harentius_blog_show', ['slug' => $page->getSlug()], true), $page->getUpdatedAt(), UrlConcrete::CHANGEFREQ_MONTHLY, 0.5), 'pages');
     }
     // Articles
     /** @var Article[] $articles */
     $articles = $this->articleRepository->findBy(['isPublished' => true], ['publishedAt' => 'DESC']);
     foreach ($articles as $article) {
         $event->getGenerator()->addUrl(new UrlConcrete($this->router->generate('harentius_blog_show', ['slug' => $article->getSlug()], true), $article->getUpdatedAt(), UrlConcrete::CHANGEFREQ_MONTHLY, 0.9), 'articles');
     }
     // Categories
     $addCategoriesRoutes = function ($categories) use($event, &$addCategoriesRoutes) {
         foreach ($categories as $category) {
             $event->getGenerator()->addUrl(new UrlConcrete($this->router->generate("harentius_blog_category_{$category['id']}", [], true), null, UrlConcrete::CHANGEFREQ_MONTHLY, 0.8), 'categories');
             $addCategoriesRoutes($category['__children']);
         }
     };
     $addCategoriesRoutes($this->categoryRepository->notEmptyChildrenHierarchy());
     // Archives
     foreach ($this->archive->getList() as $year => $months) {
         foreach ($months as $number => $name) {
             $event->getGenerator()->addUrl(new UrlConcrete($this->router->generate('harentius_blog_archive_month', ['year' => $year, 'month' => $number], true), null, UrlConcrete::CHANGEFREQ_MONTHLY, 0.6), 'archive');
         }
         $event->getGenerator()->addUrl(new UrlConcrete($this->router->generate('harentius_blog_archive_year', ['year' => $year], true), null, UrlConcrete::CHANGEFREQ_MONTHLY, 0.6), 'archive');
     }
 }