@@ -27,13 +27,24 @@ public function __construct(ContainerInterface $container)
2727 $ this ->container = $ container ;
2828 }
2929
30+ /**
31+ * Returns security context service
32+ *
33+ * @return Symfony\Component\Security\Core\SecurityContext|void The security context
34+ */
3035 public function getSecurity ()
3136 {
3237 if ($ this ->container ->has ('security.context ' )) {
3338 return $ this ->container ->get ('security.context ' );
3439 }
3540 }
3641
42+ /**
43+ * Returns current user
44+ *
45+ * @return mixed|void
46+ * @see Symfony\Component\Security\Core\Authentication\Token\TokenInterface::getUser()
47+ */
3748 public function getUser ()
3849 {
3950 if (!$ security = $ this ->getSecurity ()) {
@@ -52,17 +63,51 @@ public function getUser()
5263 return $ user ;
5364 }
5465
66+ /**
67+ * Returns security context service
68+ *
69+ * @return Symfony\Component\HttpFoundation\Request|void The http request object
70+ */
5571 public function getRequest ()
5672 {
5773 if ($ this ->container ->has ('request ' ) && $ request = $ this ->container ->get ('request ' )) {
5874 return $ request ;
5975 }
6076 }
6177
78+ /**
79+ * Returns security context service
80+ *
81+ * @return Symfony\Component\HttpFoundation\Session|void The session
82+ */
6283 public function getSession ()
6384 {
6485 if ($ request = $ this ->getRequest ()) {
6586 return $ request ->getSession ();
6687 }
6788 }
89+
90+ /**
91+ * Returns current app environment
92+ *
93+ * @return string|void The current environment string (e.g 'dev')
94+ */
95+ public function getEnvironment ()
96+ {
97+ if ($ this ->container ->hasParameter ('kernel.environment ' )) {
98+ return $ this ->container ->getParameter ('kernel.environment ' );
99+ }
100+ }
101+
102+ /**
103+ * Returns current app debug mode
104+ *
105+ * @return boolean|void The current debug mode
106+ */
107+ public function getDebug ()
108+ {
109+ if ($ this ->container ->hasParameter ('kernel.debug ' )) {
110+ return (bool )$ this ->container ->getParameter ('kernel.debug ' );
111+ }
112+ }
68113}
0 commit comments