You are here

public function StylePluginBase::getStyleOptionClassByIndex in Bootstrap Styles 1.0.x

Helper function to get the class from the options list.

Parameters

string $name: A config style name like background_color.

int $index: The index of the class at the option list.

Return value

string The class name or null.

2 calls to StylePluginBase::getStyleOptionClassByIndex()
Border::submitStyleFormElements in src/Plugin/BootstrapStyles/Style/Border.php
Margin::submitStyleFormElements in src/Plugin/BootstrapStyles/Style/Margin.php

File

src/Style/StylePluginBase.php, line 128

Class

StylePluginBase
A base class to help developers implement their own Styles Group plugins.

Namespace

Drupal\bootstrap_styles\Style

Code

public function getStyleOptionClassByIndex(string $name, int $index) {
  $class = '';
  $options = $this
    ->getStyleOptions($name);
  $count = 0;
  foreach ($options as $key => $value) {
    if ($count == $index) {
      $class = $key;
      break;
    }
    $count++;
  }
  return $class;
}