<commit_before><?php

namespace Pico\UserBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

class UserController extends Controller
{

    public function getParent(){
        return 'FOSUserBundle';
    }

    public function indexAction()
    {
        return $this->render('::base.html.twig', array(
       	'title' => 'PicoPlan'
        ));
    }

    public function confirmedAction() {
        $user = $this->getUser();
        if (!is_object($user) || !$user instanceof UserInterface) {
            throw new AccessDeniedException('This user does not have access to this section.');
        }

        return $this->render('::base.html.twig', array(
            'user' => $user,
        ));
    }

    public function homeAction() {
        /*
        * Say hello if user is logged
        */
        if ($this->get("security.context")->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
            $user = $this->get('security.context')
                ->getToken()
                ->getUser();

            $data = array(
                'user' => $user,
                );

            // Get user profile picture
            $em = $this->getDoctrine()->getManager();
            $pictureList = $em
                ->getRepository("PicoUserBundle:ProfilePicture")
                ->findBy(array(
                    "user" => $user,
                    "isActive" => true));
            foreach ($pictureList as $pic) {
                $path = $pic->getPath();
            }
            if($pictureList){
                $session = $this->getRequest()->getSession();
                $session->set("profile_pic", $path);
            }

            // Get 10 latests articles
            $articleList = $em
                ->getRepository("PicoNewsBundle:Article")
                ->findBy(
                    array(),
                    array("date" => "desc"),
                    10);
            foreach ($articleList as $article) {
                $list[$article->getId()] = array(
                    "author" => $article->getAuthor(),
                    "title" => $article->getTitle(),
                    "content" => $article->getContent(),
                    "date" => $article->getDate()->format("d-m-Y"),
                    "id" => $article->getId()
                );
            }
            $data["articles"] = $list;

            return $this->render('PicoUserBundle:User:home.html.twig', $data);
        }
        else {
            $url = $this->generateUrl('fos_user_security_login');

            return $this->redirect($url, 301);
        }

    }
<commit_msg>UserBundle: we do not force user connexion anymore<commit_after><?php

namespace Pico\UserBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

class UserController extends Controller
{

    public function getParent(){
        return 'FOSUserBundle';
    }

    public function indexAction()
    {
        return $this->render('::base.html.twig', array(
       	'title' => 'PicoPlan'
        ));
    }

    public function confirmedAction() {
        $user = $this->getUser();
        if (!is_object($user) || !$user instanceof UserInterface) {
            throw new AccessDeniedException('This user does not have access to this section.');
        }

        return $this->render('::base.html.twig', array(
            'user' => $user,
        ));
    }

    public function homeAction() {
        /*
        * Say hello if user is logged
        */
        $user = $this->get('security.context')
            ->getToken()
            ->getUser();

        $data = array(
            'user' => $user,
            );

        // Get user profile picture
        $em = $this->getDoctrine()->getManager();
        $pictureList = $em
            ->getRepository("PicoUserBundle:ProfilePicture")
            ->findBy(array(
                "user" => $user,
                "isActive" => true));
        foreach ($pictureList as $pic) {
            $path = $pic->getPath();
        }
        if($pictureList){
            $session = $this->getRequest()->getSession();
            $session->set("profile_pic", $path);
        }

        // Get 10 latests articles
        $articleList = $em
            ->getRepository("PicoNewsBundle:Article")
            ->findBy(
                array(),
                array("date" => "desc"),
                10);
        foreach ($articleList as $article) {
            $list[$article->getId()] = array(
                "author" => $article->getAuthor(),
                "title" => $article->getTitle(),
                "content" => $article->getContent(),
                "date" => $article->getDate()->format("d-m-Y"),
                "id" => $article->getId()
            );
        }
        $data["articles"] = $list;

        return $this->render('PicoUserBundle:User:home.html.twig', $data);
    }

{'fraction_non_alphanumeric': 0.1460981811069822, 'fraction_numerical': 0.0021513788382554275, 'mean_word_length': 1.6944151738672286, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5101186', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1337, 'n_words': 269}