Upgraded to Symfony 2.1-beta2

This commit is contained in:
Polonkai Gergely
2012-07-15 14:56:31 +02:00
parent c1232c9792
commit bb7aee6fee
455 changed files with 21001 additions and 18480 deletions

View File

@@ -2,10 +2,12 @@
namespace KekRozsak\FrontBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use KekRozsak\FrontBundle\Form\Type\UserType;
use KekRozsak\FrontBundle\Entity\UserData;
use KekRozsak\SecurityBundle\Form\Type\UserType;
class DefaultController extends Controller
{
@@ -14,7 +16,7 @@ class DefaultController extends Controller
*/
public function homepageAction()
{
$mainPageArticle = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Article')->findOneBy(array('mainPage' => 1), true, array('createdAt', 'DESC'), 1);
$mainPageArticle = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Article')->findOneBy(array('mainPage' => true), true, array('createdAt', 'DESC'), 1);
if (!$mainPageArticle)
throw $this->createNotFoundException('A keresett cikk nem létezik!');
@@ -23,6 +25,9 @@ class DefaultController extends Controller
/**
* @Route("/cikk/{articleSlug}", name="KekRozsakFrontBundle_article")
* @Template()
*
* @param string $articleSlug
*/
public function articleAction($articleSlug)
{
@@ -31,49 +36,43 @@ class DefaultController extends Controller
if (!$article)
throw $this->createNotFoundException('A keresett cikk nem létezik!');
return $this->render('KekRozsakFrontBundle:Default:article.html.twig', array(
'article' => $article
));
return array(
'article' => $article,
);
}
/**
* @Route("/profil", name="KekRozsakFrontBundle_profile_edit")
* @Template("KekRozsakFrontBundle:Default:userprofile.html.twig")
*/
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);
$oldPassword = $user->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
{
if ($this->getPassword() == '')
$user->setPassword($oldPassword);
}
if ($user->getUserData()->getUserId() === null)
{
$user->getUserData()->setUser($user);
}
else
$user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt()));
$em = $this->getDoctrine()->getEntityManager();
$em->persist($user);
$em->flush();
// $saveSuccess = true
}
}
return $this->render('KekRozsakFrontBundle:Default:userprofile.html.twig', array(
return array(
'form' => $form->createView(),
'saveSuccess' => $saveSuccess,
));
);
}
}