public function UrlloginController::status in urllogin 8
Same name and namespace in other branches
- 2.x src/Controller/UrlloginController.php \Drupal\urllogin\Controller\UrlloginController::status()
Displays status page.
Displays the status page that and allows a URL string to be generated for test purposes.
Parameters
int $testuid: Optional UID for generating a test URL login string.
Return value
array Page containing test results
1 string reference to 'UrlloginController::status'
File
- src/
Controller/ UrlloginController.php, line 111
Class
- UrlloginController
- Controller routines for urllogin routes.
Namespace
Drupal\urllogin\ControllerCode
public function status($testuid = 0) {
module_load_include('inc', 'urllogin', 'urllogin_security');
$element = [
'#markup' => '',
];
// Load config.
$config = $this
->config('urllogin.settings');
$codekey = $config
->get('urllogin.codekey');
$codemin = $config
->get('urllogin.codemin');
// This will sanitize it as well.
$uid = (int) $testuid;
$passphrase = urllogin_passphrase();
$page = '<ul>';
$page .= t('<li>Test UID: @uid </li>', [
'@uid' => $uid,
]);
$page .= t('<li>Passphrase: @passphrase</li>', [
'@passphrase' => $passphrase,
]);
$page .= t('<li>Current Validation number: @codekey .</li>', [
'@codekey' => $codekey,
]);
$page .= t('<li>Minimum validation number: @codemin .</li>', [
'@codemin' => $codemin,
]);
$urlstr = urllogin_encode($uid, $codekey, urllogin_passphrase());
$route_parameters = [
'urlstring' => $urlstr,
];
$page .= '<li>' . t('Encoded URL access string: [') . $urlstr . ']</li>';
$page .= '</ul>';
$testlink = 'l_test/' . $urlstr;
$testlink = Link::fromTextAndUrl($testlink, Url::fromRoute('urllogin.l_test', $route_parameters))
->toString();
$testpage = Link::fromTextAndUrl(t('the test page'), Url::fromRoute('urllogin.l_test'))
->toString();
$page .= t('<p>This page can be used to generate individual access strings for testing purposes.
Simply add the UID of the user to the end of the url for this page, revisit the page and the
access string will be displayed above.</p> <p>To test the access string,
use @testpage by appending the access string to it, e.g.: @testlink.</p>', [
'@testpage' => $testpage,
'@testlink' => $testlink,
]);
$element['#markup'] .= $page;
return $element;
}