public function webcodeRedirectAction(Request $request, $webcode)
{
$em = $this->get('em');
$linkService = $this->get('article.link');
$response = new Response();
$templatesService = $this->get('newscoop.templates.service');
$article = $em->getRepository('Newscoop\\Entity\\Article')->createQueryBuilder('a')->where('a.webcode = :webcode')->setParameter('webcode', str_replace('+', '', $webcode))->getQuery()->getOneOrNullResult();
if (!is_null($article) && $article->isPublished()) {
$link = $linkService->getLink($article);
return $this->redirect($link, 301);
}
$response->setContent($templatesService->fetchTemplate('404.tpl'));
$response->setStatusCode(Response::HTTP_NOT_FOUND);
return $response;
}