@@ -34,12 +34,42 @@ public function buildForm(array $form, FormStateInterface $form_state) {
3434 '#type ' => 'checkbox ' ,
3535 '#title ' => $ this ->t ('UBC CWL Debug Mode ' ),
3636 '#default_value ' => $ config ->get ('ubc_cwl_auth_debug ' ),
37- '#description ' => $ this ->t ('Turn on debug mode ' ),
37+ '#description ' => $ this ->t ('Turn on debug mode. Log SAML responses. ' ),
3838 '#return_value ' => 1 ,
3939 ];
4040
41+ $ form ['attr1 ' ] = [
42+ '#type ' => 'textfield ' ,
43+ '#title ' => $ this ->t ('Attribute 1 ' ),
44+ '#default_value ' => $ config ->get ('ubc_cwl_auth_attr1 ' ),
45+ ];
46+
47+ $ form ['attr2 ' ] = [
48+ '#type ' => 'textfield ' ,
49+ '#title ' => $ this ->t ('Attribute 2 ' ),
50+ '#default_value ' => $ config ->get ('ubc_cwl_auth_attr2 ' ),
51+ ];
52+
53+ $ form ['attr3 ' ] = [
54+ '#type ' => 'textfield ' ,
55+ '#title ' => $ this ->t ('Attribute 3 ' ),
56+ '#default_value ' => $ config ->get ('ubc_cwl_auth_attr3 ' ),
57+ ];
58+
59+ $ form ['attr4 ' ] = [
60+ '#type ' => 'textfield ' ,
61+ '#title ' => $ this ->t ('Attribute 4 ' ),
62+ '#default_value ' => $ config ->get ('ubc_cwl_auth_attr4 ' ),
63+ ];
64+
65+ $ form ['attr5 ' ] = [
66+ '#type ' => 'textfield ' ,
67+ '#title ' => $ this ->t ('Attribute 5 ' ),
68+ '#default_value ' => $ config ->get ('ubc_cwl_auth_attr5 ' ),
69+ ];
70+
4171 $ form ['attributes ' ] = [
42- '#markup ' => $ this ->getDebugAttributes (),
72+ '#markup ' => $ this ->getDebugAttributes ($ config ),
4373 ];
4474
4575 return parent ::buildForm ($ form , $ form_state );
@@ -51,18 +81,44 @@ public function buildForm(array $form, FormStateInterface $form_state) {
5181 public function submitForm (array &$ form , FormStateInterface $ form_state ) {
5282 $ this ->config ('ubc_cwl_auth.settings ' )
5383 ->set ('ubc_cwl_auth_debug ' , $ form_state ->getValue ('debug ' ))
84+ ->set ('ubc_cwl_auth_attr1 ' , $ form_state ->getValue ('attr1 ' ))
85+ ->set ('ubc_cwl_auth_attr2 ' , $ form_state ->getValue ('attr2 ' ))
86+ ->set ('ubc_cwl_auth_attr3 ' , $ form_state ->getValue ('attr3 ' ))
87+ ->set ('ubc_cwl_auth_attr4 ' , $ form_state ->getValue ('attr4 ' ))
88+ ->set ('ubc_cwl_auth_attr5 ' , $ form_state ->getValue ('attr5 ' ))
5489 ->save ();
5590
5691 \Drupal::logger ('ubc_cwl_auth ' )->notice ('UBC_CWL_AUTH Debug Setting: ' .$ form_state ->getValue ('debug ' ));
5792
5893 parent ::submitForm ($ form , $ form_state );
5994 }
6095
61- private function getDebugAttributes () {
96+ /**
97+ * Fetch rows from the cache_ubc_cwl_auth table and display
98+ */
99+ private function getDebugAttributes ($ config ) {
100+
101+ if ($ config ->get ('ubc_cwl_auth_debug ' ) != 1 ) {
102+ return '' ;
103+ }
104+
105+ $ database = \Drupal::database ();
106+ $ query = $ database ->select ('cache_ubc_cwl_auth ' , 'c ' )
107+ ->fields ('c ' , ['cid ' , 'data ' ]);
108+ $ result = $ query ->execute ()->fetchAll ();
62109
63- //\Drupal::logger('samlauth')->debug('Test SAML debug message from test');
110+ $ table = '<table><thead><tr><th>CID</th><th>DATA</th></tr></thead> ' ;
111+ foreach ($ result as $ item ) {
112+ $ cid = $ item ->cid ;
113+ $ data = json_decode ($ item ->data );
114+ $ data = (array )$ data ;
64115
65- return '<p>TODO: fetch data from Cache</p> ' ;
116+ $ table .= '<tr><td> ' .$ cid .'</td><td> ' .print_r ($ data , true ).'</td></tr> ' ;
117+ }
118+ $ table .= '</table> ' ;
119+
120+ return $ table ;
66121 }
67122
123+
68124}
0 commit comments