You are here

public function SkypeManager::getAttributes in Skype 8

Returns atrributes.

Return value

\Drupal\Core\Template\Attribute

File

src/Manager/SkypeManager.php, line 98

Class

SkypeManager

Namespace

Drupal\skype\Manager

Code

public function getAttributes() {
  $attributes = [];
  $classes = [
    $this->config
      ->get('initiate_chat'),
  ];
  $initiate_chat = $this->config
    ->get('initiate_chat');
  $button_style = $this->config
    ->get('button_style');
  if ($initiate_chat == 'skype-button') {

    // If button is chosen, add class to indicate button style.
    array_push($classes, $button_style);
    if ($button_style == 'rectangle' || $button_style == 'rounded') {

      // Allow to add button text and button color.
      if ($button_text = $this->config
        ->get('button_text')) {
        $attributes['data-text'] = $button_text;
      }
      if ($button_color = $this->config
        ->get('button_color')) {
        $attributes['data-color'] = $button_color;
      }
      if ($this->config
        ->get('text_only')) {
        array_push($classes, 'textonly');
      }
    }
  }
  elseif ($initiate_chat == 'skype-chat') {
    $attributes['data-can-collapse'] = $this->config
      ->get('chat_can_collapse') ? 'true' : 'false';
    $attributes['data-can-close'] = $this->config
      ->get('chat_can_close') ? 'true' : 'false';
    $attributes['data-can-upload-file'] = $this->config
      ->get('chat_can_upload_file') ? 'true' : 'false';
    $attributes['data-entry-animation'] = $this->config
      ->get('chat_enable_animation') ? 'true' : 'false';
    $attributes['data-show-header'] = $this->config
      ->get('chat_enable_header') ? 'true' : 'false';
  }
  $attributes['class'] = $classes;
  return new Attribute($attributes);
}