You are here

function rrssb_button_config in Ridiculously Responsive Social Sharing Buttons 8.2

Fetch config for all buttons.

Return value

array Key is button name, value is an array of button config. For config values, see hook_rrssb_buttons.

3 calls to rrssb_button_config()
drush_rrssb_gen_css in includes/rrssb.drush.inc
Implementation of drush_hook_COMMAND().
RRSSBSettingsForm::form in src/Form/RRSSBSettingsForm.php
Gets the actual form array to be built.
rrssb_settings in ./rrssb.module
Fetch buttons settings.

File

./rrssb.module, line 281

Code

function rrssb_button_config() {
  $buttons =& drupal_static(__FUNCTION__);
  if (isset($buttons)) {
    return $buttons;
  }
  if ($cache = \Drupal::cache()
    ->get('rrssb_buttons')) {
    return $cache->data;
  }
  $buttons = Drupal::moduleHandler()
    ->invokeAll('rrssb_buttons');
  Drupal::moduleHandler()
    ->alter('rrssb_buttons', $buttons);
  $iconsDir = rrssb_library_path() . '/icons';

  // Set some defaults.
  foreach ($buttons as $name => &$button) {
    if (!isset($button['svg'])) {

      // Read SVG from file.
      $svgfile = isset($button['svgfile']) ? $button['svgfile'] : "<icons>/{$name}.min.svg";
      $svgfile = str_replace('<icons>', $iconsDir, $svgfile);
      $button['svg'] = file_get_contents($svgfile);
    }

    // Default text to name.
    if (!isset($button['text'])) {
      $button['text'] = $name;
    }
    if (!isset($button['title_follow'])) {
      $button['title_follow'] = $button['text'];
    }
    if (!isset($button['popup'])) {
      $button['popup'] = TRUE;
    }
  }
  \Drupal::cache()
    ->set('rrssb_buttons', $buttons);
  return $buttons;
}