Permalink
Browse files

Controller corrections to do the variable dumping in the control and …

…only display the output on the page.
  • Loading branch information...
1 parent 3170c0f commit b334bef84efe208c836a12374d96300b84c8ee88 @raystorm committed Feb 26, 2014
@@ -60,8 +60,9 @@ public function AdminAction(Request $request)
return $this->render( 'ResumeBundle:Default:admin.html.twig',
array( "page_title" => "Tom Burton's Portfolio",
"user" => $user,
+ "userDump" => print_r($user,true),
"form" => $form->createView(),
- "attributes" => $attributes,
+ "attributes" => print_r($attributes,true),
"result" => $result));
}
@@ -4,8 +4,6 @@
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-use Symfony\Component\HttpFoundation\Request;
-
class DefaultController extends Controller
{
//TODO: add template actions
@@ -15,12 +13,15 @@ public function indexAction()
$name = "Not Logged In";
$securityContext = $this->get('security.context');
- $user = $securityContext->getToken()->getUser();
- if ( $user ) { $name = $user; }
+ $token = $securityContext->getToken();
+
+ if ( $token && $securityContext->isGranted('IS_AUTHENTICATED_OPENID') )
+ { $name = $token->getUser()->getUserName(); }
return $this->render( 'ResumeBundle:Default:index.html.twig',
- array( "page_title" => "Tom Burton's Portfolio",
- "userName" => $name));
+ array( "page_title" => "Tom Burton's Portfolio",
+ "userName" => $token->getUser(),
+ "welcomeName" => $name));
}
public function aboutAction()
@@ -34,4 +35,6 @@ public function contactAction()
return $this->render('ResumeBundle:Default:contact.html.twig',
array( "page_title" => "Contact") );
}
+
+ public function dump($var) { return print_r($var, true); }
}
@@ -12,12 +12,12 @@
<p>
<h3>User Object</h3>
- <code style="white-space: pre; display: block;">{{ dump(user) }}</code>
+ <code style="white-space: pre; display: block;">{{ userDump }}</code>
</p>
<p>
<h3>User Attributes</h3>
- <code style="white-space: pre; display: block;">{{ dump(attributes) }}</code>
+ <code style="white-space: pre; display: block;">{{ attributes }}</code>
</p>
<h2>Resume Upload</h2>
@@ -6,9 +6,9 @@
<div class="hero-unit">
<h1>{{ fullName }}</h1>
<p>{{ fullName }} is an excellent Web Application Developer.</p>
- <P>
- Welcome {{ dump(userName) }}!
- </P>
+ {% if welcomeName %}
+ <P> Welcome {{ welcomeName }}! </P>
+ {% endif %}
<p>
<a href="#" class="btn btn-primary btn-large">Learn more &raquo;</a>
</p>

0 comments on commit b334bef

Please sign in to comment.