| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 71 | 
| Code Lines | 15 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 1 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php | ||
| 53 | public function ssoAction($integration,Request $request) | ||
| 54 |     { | ||
| 55 | $session = $this->request->getSession(); | ||
| 56 |         if (isset($_SERVER['PHP_AUTH_USER'])){ | ||
| 57 |             //$session->remove('_security.last_error'); | ||
| 58 |             //$session->remove('_csrf/https-authenticate'); | ||
| 59 | |||
| 60 | //$session->clear(); | ||
| 61 | //die(); | ||
| 62 | //return $this->redirect( '/s/sso_login/LdapAuth',302); | ||
| 63 | } | ||
| 64 | |||
| 65 | |||
| 66 |         $this->parametersHelper = $this->get('mautic.helper.core_parameters'); | ||
| 67 | //print_r($session); | ||
| 68 | // Get a list of SSO integrations | ||
| 69 |         $integrationHelper = $this->get('mautic.helper.integration'); | ||
| 70 | $integrations = $integrationHelper->getIntegrationObjects(null, [], true, null, true); | ||
| 71 | $integration = $integrations['LdapAuth']; | ||
| 72 | /*$settings = [ | ||
| 73 |             'hostname'      => $this->parametersHelper->getParameter('ldap_auth_host'), | ||
| 74 |             'port'          => $this->parametersHelper->getParameter('ldap_auth_port', 389), | ||
| 75 |             'ssl'           => $this->parametersHelper->getParameter('ldap_auth_ssl', false), | ||
| 76 |             'starttls'      => $this->parametersHelper->getParameter('ldap_auth_starttls', true), | ||
| 77 |             'version'       => $this->parametersHelper->getParameter('ldap_auth_version', 3), | ||
| 78 | // TODO Coming feature: Bind DN | ||
| 79 |             //'bind_dn'       => $this->parametersHelper->getParameter('ldap_auth_bind_dn'), | ||
| 80 |             //'bind_passwd'   => $this->parametersHelper->getParameter('ldap_auth_bind_passwd'), | ||
| 81 |             'base_dn'       => $this->parametersHelper->getParameter('ldap_auth_base_dn'), | ||
| 82 |             'user_query'    => $this->parametersHelper->getParameter('ldap_auth_user_query', ''), | ||
| 83 |             'is_ad'         => $this->parametersHelper->getParameter('ldap_auth_isactivedirectory', false), | ||
| 84 |             'ad_domain'     => $this->parametersHelper->getParameter('ldap_auth_activedirectory_domain', null), | ||
| 85 |             'user_key'      => $this->parametersHelper->getParameter('ldap_auth_username_attribute', 'uid'), | ||
| 86 |             'user_email'    => $this->parametersHelper->getParameter('ldap_auth_email_attribute', 'mail'), | ||
| 87 |             'user_firstname'=> $this->parametersHelper->getParameter('ldap_auth_firstname_attribute', 'givenName'), | ||
| 88 |             'user_lastname' => $this->parametersHelper->getParameter('ldap_auth_lastname_attribute', 'sn'), | ||
| 89 |             'user_fullname' => $this->parametersHelper->getParameter('ldap_auth_fullname_attribute', 'displayName'), | ||
| 90 | ]; | ||
| 91 | $parameters = array( | ||
| 92 | 'login'=>$_SERVER['PHP_AUTH_USER'], | ||
| 93 | 'password'=>'', | ||
| 94 | 'email'=> '[email protected]' | ||
| 95 | ); | ||
| 96 | //GET USER | ||
| 97 | //$user = $integration->getUserSimple($settings,$parameters); | ||
| 98 | $user = new User(); | ||
| 99 | $user->setUsername($parameters['login']) | ||
| 100 | ->setEmail($parameters['email']) | ||
| 101 | ->setFirstName($parameters['login']) | ||
| 102 | ->setLastName($parameters['login']) | ||
| 103 | ->setRole( | ||
| 104 | $integration->getUserRole() | ||
| 105 | ); | ||
| 106 | |||
| 107 | $token = new UsernamePasswordToken($user, '', 'main',array()); | ||
| 108 |         $this->get('security.token_storage')->setToken($token); | ||
| 109 | |||
| 110 |         $this->get('session')->set('_security_main', serialize($token)); | ||
| 111 | $event = new InteractiveLoginEvent($request, $token); | ||
| 112 |         $this->get("event_dispatcher")->dispatch("security.interactive_login", $event);*/ | ||
| 113 | |||
| 114 | return $this->delegateView([ | ||
| 115 | 'viewParameters' => [ | ||
| 116 | 'last_username' => $session->get(Security::LAST_USERNAME), | ||
| 117 | 'integrations' => $integrations, | ||
| 118 | ], | ||
| 119 | 'contentTemplate' => 'MauticUserBundle:Security:login.html.php', | ||
| 120 | 'passthroughVars' => [ | ||
| 121 |                 'route'          => $this->generateUrl('login'), | ||
| 122 | 'mauticContent' => 'user', | ||
| 123 | 'sessionExpired' => true, | ||
| 124 | ], | ||
| 127 | } |