/**
  * {@inheritdoc}
  */
 public function preprocessElement(Variables $variables, $hook, array $info)
 {
     // Create variables for #input_group and #input_group_button flags.
     $variables['input_group'] = $variables->element->getProperty('input_group') || $variables->element->getProperty('input_group_button');
     // Map the element properties.
     $variables->map(['attributes' => 'attributes', 'field_prefix' => 'prefix', 'field_suffix' => 'suffix']);
     // Ensure attributes are proper objects.
     $this->preprocessAttributes($variables, $hook, $info);
 }
 /**
  * {@inheritdoc}
  */
 public function preprocessElement(Variables $variables, $hook, array $info)
 {
     $variables->element->colorize();
     $variables->element->setButtonSize();
     $variables->element->setIcon($variables->element->getProperty('icon'));
     $variables['icon_only'] = $variables->element->getProperty('icon_only');
     $variables['label'] = $variables->element->getProperty('value');
     if ($variables->element->getProperty('split')) {
         $variables->map([$variables::SPLIT_BUTTON]);
     }
     parent::preprocessElement($variables, $hook, $info);
 }
 /**
  * {@inheritdoc}
  */
 public function preprocessElement(Variables $variables, $hook, array $info)
 {
     $variables->element->map(['id', 'name', 'value', 'type']);
     // Autocomplete.
     if ($route = $variables->element->getProperty('autocomplete_route_name')) {
         $variables['autocomplete'] = TRUE;
     }
     // Create variables for #input_group and #input_group_button flags.
     $variables['input_group'] = $variables->element->getProperty('input_group') || $variables->element->getProperty('input_group_button');
     // Map the element properties.
     $variables->map(['attributes' => 'attributes', 'icon' => 'icon', 'field_prefix' => 'prefix', 'field_suffix' => 'suffix', 'type' => 'type']);
     // Ensure attributes are proper objects.
     $this->preprocessAttributes($variables, $hook, $info);
 }
 /**
  * {@inheritdoc}
  */
 public function preprocessVariables(Variables $variables, $hook, array $info)
 {
     if ($variables->theme_hook_original === 'links' && $variables->hasClass('operations')) {
         $variables->addClass('list-inline');
         foreach ($variables->links as &$data) {
             $link = Element::create($data['link']);
             $link->addClass(['btn', 'btn-sm']);
             $link->colorize();
             $link->setIcon();
             if ($this->theme->getSetting('tooltip_enabled')) {
                 $link->setAttribute('data-toggle', 'tooltip');
                 $link->setAttribute('data-placement', 'bottom');
             }
         }
     }
     $this->preprocessAttributes($variables, $hook, $info);
 }
 /**
  * Converts any set description variable into a traversable array.
  *
  * @param \Drupal\materialize\Utility\Variables $variables
  *   A variables object.
  * @param string $hook
  *   The name of the theme hook.
  * @param array $info
  *   The theme hook info array.
  *
  * @see https://www.drupal.org/node/2324025
  */
 protected function preprocessDescription(Variables $variables, $hook, array $info)
 {
     if ($variables->offsetGet('description')) {
         // Retrieve the description attributes.
         $description_attributes = $variables->offsetGet('description_attributes', []);
         // Remove standalone description attributes.
         $variables->offsetUnset('description_attributes');
         // Build the description attributes.
         if ($id = $variables->getAttribute('id')) {
             $variables->setAttribute('aria-describedby', "{$id}--description");
             $description_attributes['id'] = "{$id}--description";
         }
         // Replace the description variable.
         $variables->offsetSet('description', ['attributes' => new Attribute($description_attributes), 'content' => $variables['description'], 'position' => $variables->offsetGet('description_display', 'after')]);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function preprocessVariables(Variables $variables, $hook, array $info)
 {
     // Add information about the number of sidebars.
     $variables['content_column_attributes'] = new Attribute();
     $variables['content_column_attributes']['class'] = array();
     if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) {
         $variables['content_column_attributes']['class'][] = 'col-s6';
     } elseif (!empty($variables['page']['sidebar_first']) || !empty($variables['page']['sidebar_second'])) {
         $variables['content_column_attributes']['class'][] = 'col-s9';
     } else {
         $variables['content_column_attributes']['class'][] = 'col-s12';
     }
     // Settings for fixed navbar.
     if (theme_get_setting('fixed_header') === 1) {
         $variables['navbar_attributes'] = new Attribute();
         $variables['navbar_attributes']['class'] = array('navbar-fixed');
     }
     // Logo.
     $url = Url::fromRoute('<front>');
     $link_options = array('attributes' => array('class' => array('brand-logo')));
     $url->setOptions($link_options);
     $variables['logo'] = \Drupal::l(t('Logo'), $url);
     // User nav.
     // User page.
     $url = Url::fromRoute('user.page');
     $variables['user_page'] = \Drupal::l(t('<i class="small left material-icons">perm_identity</i>' . 'Account'), $url);
     // Log in/log out.
     // @TODO Change on system menu user link (log in/log out).
     $url = Url::fromRoute('user.logout');
     $variables['user_logout'] = \Drupal::l(t('<i class="small left material-icons">open_in_new</i>' . 'Log out'), $url);
     // Setup default attributes.
     $variables->getAttributes(DrupalAttributes::NAVBAR);
     $variables->getAttributes(DrupalAttributes::HEADER);
     $variables->getAttributes(DrupalAttributes::CONTENT);
     $variables->getAttributes(DrupalAttributes::FOOTER);
     $this->preprocessAttributes($variables, $hook, $info);
 }
 /**
  * {@inheritdoc}
  */
 public function preprocessElement(Variables $variables, $hook, array $info)
 {
     $variables->map(['attributes']);
     $this->preprocessAttributes($variables, $hook, $info);
 }