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,
));
);
}
}

View File

@@ -2,9 +2,10 @@
namespace KekRozsak\FrontBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use KekRozsak\FrontBundle\Entity\ForumPost;
use KekRozsak\FrontBundle\Form\Type\ForumPostType;
@@ -16,40 +17,42 @@ class ForumController extends Controller
{
/**
* @Route("", name="KekRozsakFrontBundle_forum_main")
* @Template("KekRozsakFrontBundle:Forum:topic_group_list.html.twig")
*/
public function mainAction()
{
// TODO: Protect this controller with roles? It is also defined in security.yml
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup');
// TODO: ORDER the topic list by last post date
$topicGroups = $groupRepo->findAll();
return $this->render('KekRozsakFrontBundle:Forum:topic_group_list.html.twig', array(
return array(
'topicGroups' => $topicGroups,
));
);
}
/**
* @Route("/{topicGroupSlug}", name="KekRozsakFrontBundle_forum_topic_list")
* @Template("KekRozsakFrontBundle:Forum:topic_list.html.twig")
*/
public function topicListAction($topicGroupSlug)
{
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup');
if (!($topicGroup = $groupRepo->findOneBySlug($topicGroupSlug)))
throw $this->createNotFoundException('A kért témakör nem létezik!');
return $this->render('KekRozsakFrontBundle:Forum:topic_list.html.twig', array(
return array(
'topicGroup' => $topicGroup,
));
);
}
/**
* @Route("/{topicGroupSlug}/{topicSlug}", name="KekRozsakFrontBundle_forum_post_list")
* @Template("KekRozsakFrontBundle:Forum:post_list.html.twig")
*/
public function postListAction($topicGroupSlug, $topicSlug)
{
$request = $this->getRequest();
// Get the topic group based on slug
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup');
if (!($topicGroup = $groupRepo->findOneBySlug($topicGroupSlug)))
@@ -68,6 +71,7 @@ class ForumController extends Controller
$post = new ForumPost();
$form = $this->createForm(new ForumPostType($topicGroup->getId(), $topic->getId()), $post);
$request = $this->getRequest();
if ($request->getMethod() == 'POST')
{
$form->bindRequest($request);
@@ -89,12 +93,11 @@ class ForumController extends Controller
}
}
return $this->render('KekRozsakFrontBundle:Forum:post_list.html.twig', array(
return array(
'topicGroup' => $topicGroup,
'topic' => $topic,
'posts' => $posts,
'form' => $form->createView(),
));
);
}
}