The SSH host key has changed on 8 April, 2022 to this one: SHA256:573uTBSeh74kvOo0HJXi5ijdzRm8me27suzNEDlGyrQ
blueroses.hu project repository
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
kekrozsak/src/KekRozsak/FrontBundle/Controller/DefaultController.php

69 lines
2.0 KiB

<?php
namespace KekRozsak\FrontBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use KekRozsak\FrontBundle\Form\Type\UserType;
class DefaultController extends Controller
{
public function homepageAction()
{
$mainPageArticle = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Article')->findOneBy(array('main_page' => 1), true, array('created_at', 'DESC'), 1);
if (!$mainPageArticle)
throw $this->createNotFoundException('A keresett cikk nem létezik!');
return $this->forward('KekRozsakFrontBundle:Default:article', array('articleSlug' => $mainPageArticle->getSlug()));
}
public function articleAction($articleSlug)
{
$article = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Article')->findOneBySlug($articleSlug);
if (!$article)
throw $this->createNotFoundException('A keresett cikk nem létezik!');
return $this->render('KekRozsakFrontBundle:Default:article.html.twig', array(
'article' => $article
));
}
public function profileEditAction()
{
$user = $this->get('security.context')->getToken()->getUser();
$oldPassword = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:User')->findOneById($user->getId())->getPassword();
$form = $this->createForm(new UserType(), $user);
$saveSuccess = false;
$request = $this->getRequest();
if ($request->getMethod() == 'POST')
{
$form->bindRequest($request);
if ($form->isValid())
{
if ($user->getPassword() != '')
{
$user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt()));
}
else
{
$user->setPassword($oldPassword);
}
if ($user->getUserData()->getUserId() === null)
{
$user->getUserData()->setUser($user);
}
$em = $this->getDoctrine()->getEntityManager();
$em->persist($user);
$em->flush();
// $saveSuccess = true
}
}
return $this->render('KekRozsakFrontBundle:Default:userprofile.html.twig', array(
'form' => $form->createView(),
'saveSuccess' => $saveSuccess,
));
}
}