Refactored code to comply with PSR-*

Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely POLONKAI
2012-08-16 15:52:41 +02:00
parent de00a6ad21
commit fab08cad6f
69 changed files with 5253 additions and 4673 deletions

View File

@@ -15,50 +15,58 @@ use KekRozsak\SecurityBundle\Form\Type\UserType;
class DefaultController extends Controller
{
/**
* @Route("/", name="KekRozsakFrontBundle_homepage")
*/
public function homepageAction()
{
$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!');
/**
* @Route("/", name="KekRozsakFrontBundle_homepage")
*/
public function homepageAction()
{
$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!');
}
return $this->forward('KekRozsakFrontBundle:Article:view', array('slug' => $mainPageArticle->getSlug()));
}
return $this->forward('KekRozsakFrontBundle:Article:view', array('slug' => $mainPageArticle->getSlug()));
}
/**
* @Route("/profil", name="KekRozsakFrontBundle_profile_edit")
* @Template("KekRozsakFrontBundle:Default:userprofile.html.twig")
*/
public function profileEditAction()
{
$user = $this->get('security.context')->getToken()->getUser();
/**
* @Route("/profil", name="KekRozsakFrontBundle_profile_edit")
* @Template("KekRozsakFrontBundle:Default:userprofile.html.twig")
*/
public function profileEditAction()
{
$user = $this->get('security.context')->getToken()->getUser();
$oldPassword = $user->getPassword();
$form = $this->createForm(new UserType(), $user);
$saveSuccess = false;
$request = $this->getRequest();
$oldPassword = $user->getPassword();
$form = $this->createForm(new UserType(), $user);
$saveSuccess = false;
$request = $this->getRequest();
if ($request->getMethod() == 'POST')
{
$form->bind($request);
if ($form->isValid())
{
if ($user->getPassword() == '')
$user->setPassword($oldPassword);
else
$user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt()));
if ($request->getMethod() == 'POST') {
$form->bind($request);
if ($form->isValid()) {
if ($user->getPassword() == '') {
$user->setPassword($oldPassword);
} else {
$user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt()));
}
$em = $this->getDoctrine()->getEntityManager();
$em->persist($user);
$em->flush();
}
}
$em = $this->getDoctrine()->getEntityManager();
$em->persist($user);
$em->flush();
}
}
return array(
'form' => $form->createView(),
'saveSuccess' => $saveSuccess,
);
}
return array(
'form' => $form->createView(),
'saveSuccess' => $saveSuccess,
);
}
}