Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. $form['#tree'] = TRUE;
  2. $form['clients_enabled'] = array(
  3. '#title' => t('Enable PixelPin OpenID Connect'),
  4. '#type' => 'checkboxes',
  5. '#options' => array('pixelpin' => $this->t('Enable')),
  6. '#default_value' => $clients_enabled,
  7. );
  8.  
  9. public function buildForm(array $form, FormStateInterface $form_state) {
  10. $definitions = $this->pluginManager->getDefinitions();
  11. foreach ($definitions as $client_id => $client) {
  12. foreach ($this->pluginManager->getDefinitions() as $client_name => $client_plugin) {
  13. if (!$this->config('pixelpin_openid_connect.settings.' . $client_id)
  14. ->get('enabled')) {
  15. $url = Drupal::service('path.current')->getPath();
  16.  
  17. $find = 'login';
  18.  
  19. $pos = strpos($url, $find);
  20.  
  21. if ($pos === false){
  22. $value = 'Register Using @client_title';
  23. } else {
  24. $value = 'Log in with @client_title';
  25. }
  26.  
  27. $element = 'clients_enabled[' . $client_plugin['id'] . ']';
  28. $form['pixelpin_openid_connect_client_' . $client_id . '_login'] = array(
  29. '#type' => 'submit',
  30. '#value' => t($value, array(
  31. '@client_title' => $client['label'],
  32. )),
  33. 'visible' => array(
  34. ':input[name="' . $element . '"]' => array('checked' => TRUE),
  35. ),
  36. '#name' => $client_id,
  37. '#prefix' => '<div>',
  38. '#suffix' => '</div>',
  39. );
  40. }
  41. }
  42. }
  43. return $form;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement