src/ApplicationBundle/Controller/GenericController.php line 67

Open in your IDE?
  1. <?php
  2. namespace ApplicationBundle\Controller;
  3. use ApplicationBundle\Modules\Authentication\Constants\UserConstants; use ApplicationBundle\Modules\Api\Constants\ApiConstants;
  4. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  5. class GenericController extends Controller
  6. {
  7.     public function cleanUtf8($data)
  8.     {
  9.         if (is_array($data)) {
  10.             return array_map([$this'cleanUtf8'], $data);
  11.         }
  12.         if (is_string($data)) {
  13.             return mb_convert_encoding($data'UTF-8''UTF-8');
  14.         }
  15.         return $data;
  16.     }
  17.     /**
  18.      * Returns the logged user id
  19.      *
  20.      * @param object $req
  21.      *
  22.      * @return integer
  23.      */
  24.     public function loggedUserId($req)
  25.     {
  26.         $session $req->getSession();
  27.         return $session->get(UserConstants::USER_ID);
  28.     }
  29.     /**
  30.      * Returns the logged user type
  31.      *
  32.      * @param object $req
  33.      *
  34.      * @return integer
  35.      */
  36.     public function loggedUserType($req)
  37.     {
  38.         $session $req->getSession();
  39.         return $session->get(UserConstants::USER_TYPE);
  40.     }
  41.     /**
  42.      * Returns the logged user login id
  43.      *
  44.      * @param object $req
  45.      *
  46.      * @return integer
  47.      */
  48.     public function getLoggedUserLoginId($req)
  49.     {
  50.         $session $req->getSession();
  51.         return $session->get(UserConstants::USER_LOGIN_ID);
  52.     }
  53.     public function getLoggedUserCompanyId($req)
  54.     {
  55.         $session $req->getSession();
  56.         return $session->get(UserConstants::USER_COMPANY_ID);
  57.     }
  58.     public function getSysUser($id)
  59.     {
  60.         $em $this->getDoctrine()->getManager();
  61.         $user $em -> getRepository('ApplicationBundle\\Entity\\SysUser')->findOneBy(['userId'=>$id]);
  62.         return $user;
  63.     }
  64. }