public function drupalchatController::drupalchat_app_settings in DrupalChat 8
Function to render drupalchat app settings iframe.
1 string reference to 'drupalchatController::drupalchat_app_settings'
File
- src/
Controller/ drupalchatController.php, line 1035 - Contains Drupal\drupalchat\Controller\drupalchatController
Class
Namespace
Drupal\drupalchat\ControllerCode
public function drupalchat_app_settings() {
// Load the current user.
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()
->id());
$user_name = $user
->getUsername();
if (isset($_SESSION['token']) && !empty($_SESSION['token'])) {
$token = $_SESSION['token'];
}
else {
$json = drupalchatController::_drupalchat_get_auth(array());
$token = $json->key;
}
$drupalchat_host = DRUPALCHAT_EXTERNAL_A_HOST;
$host = explode("/", $drupalchat_host);
$host_name = $host[2];
$dashboardUrl = "//" . DRUPALCHAT_EXTERNAL_CDN_HOST . "/apps/dashboard/#/app-settings?sessid=" . $token . "&hostName=" . $host_name . "&hostPort=" . DRUPALCHAT_EXTERNAL_A_PORT;
// return array(
// '#markup' => '<iframe id="app_settings" width="90%" height="800px" border="none" src = "'.$dashboardUrl.'"></iframe>',
// '#allowed_tags' => ['iframe'],
// );
$form = array();
$form['drupalchat_app_dashboard'] = array(
'#type' => 'button',
'#attributes' => array(
'onClick' => 'window.open("' . $dashboardUrl . '","_blank")',
),
'#value' => t('Click here to open App Dashboard'),
);
return $form;
}