Advertisement
Guest User

Untitled

a guest
May 24th, 2019
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.12 KB | None | 0 0
  1. public function companyAccess($slug, $access = false, $route = false, $parameters = []){
  2.         $info = $this->entityManager->getRepository(CompanyAccounts::class)
  3.             ->getCompanyBySlugAndAccount($slug, $this->container->get(Accounts::class)->getAccount());
  4.  
  5.         $forbidden = !$info || ($info && $access && !$info->$access())? true : false;
  6.  
  7.         if($forbidden){
  8.             if(!$info)
  9.                 $message = "Опитвате се да достъпите компания, която не съществува или такава до която Вие нямате достъп";
  10.             else
  11.                 $message = "Вие нямате достъп до тази страница. Моля, свържете се с вашият мениджър за повече информация";
  12.  
  13.             $router = !$info || !$route ? "index_companies" : $route;
  14.             $parameters = !$info || !$parameters ? [] : $parameters;
  15.  
  16.             $this->flashbag->add('danger', $message);
  17.             $this->redirect($this->router->generate($router, $parameters));
  18.         }
  19.  
  20.         return $info;
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement