webservice = $webservice; $this->urlBase = $urlBase; $this->request = $request->getCurrentRequest(); } /** * @return array */ public function getFunctions() { return array( new \Twig_SimpleFunction('is_granted_previous_admin', array($this, 'isGrantedPreviousAdmin')), new \Twig_SimpleFunction('switch_user_exit', array($this, 'switchUserExit')), ); } /** * @return boolean */ public function isGrantedPreviousAdmin() { try { $url = "https://{$this->urlBase}/admin/user/is_granted"; $cookies = $this->request->cookies->all(); $response = $this->webservice->makeGetRequest($url, HttpRequestInterface::METHOD_GET, [], null, $cookies); return json_decode($response); } catch (\Exception $e) { return false; } } /** * @return boolean */ public function switchUserExit() { return 'https://' . $this->urlBase . '/?_switch_user=_exit'; } /** * @return string */ public function getName() { return 'is_granted_previous_admin_extension'; } }