ColorboxSettingsForm.php 19.8 KB
Newer Older
grisendo's avatar
grisendo committed
1
<?php
2

grisendo's avatar
grisendo committed
3 4
namespace Drupal\colorbox\Form;

5 6
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
grisendo's avatar
grisendo committed
7
use Drupal\Core\Form\ConfigFormBase;
8
use Drupal\Core\Form\FormStateInterface;
9
use Symfony\Component\DependencyInjection\ContainerInterface;
grisendo's avatar
grisendo committed
10 11 12 13

/**
 * General configuration form for controlling the colorbox behaviour..
 */
grisendo's avatar
grisendo committed
14
class ColorboxSettingsForm extends ConfigFormBase {
grisendo's avatar
grisendo committed
15

16 17 18 19 20 21 22 23 24 25
  /**
   * A state that represents the custom settings being enabled.
   */
  const STATE_CUSTOM_SETTINGS = 0;

  /**
   * A state that represents the slideshow being enabled.
   */
  const STATE_SLIDESHOW_ENABLED = 1;

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
  /**
   * Drupal\Core\Extension\ModuleHandlerInterface definition.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  private $moduleHandler;

  /**
   * Class constructor.
   */
  public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $moduleHandler) {
    parent::__construct($config_factory);
    $this->moduleHandler = $moduleHandler;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('config.factory'),
      $container->get('module_handler')
    );
  }

grisendo's avatar
grisendo committed
51 52 53
  /**
   * {@inheritdoc}
   */
54
  public function getFormId() {
55
    return 'colorbox_admin_settings_form';
grisendo's avatar
grisendo committed
56 57
  }

58
  /**
59 60 61
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
62
    return ['colorbox.settings'];
63 64
  }

grisendo's avatar
grisendo committed
65 66 67
  /**
   * {@inheritdoc}
   */
68
  public function buildForm(array $form, FormStateInterface $form_state) {
grisendo's avatar
grisendo committed
69

70
    $config = $this->configFactory->get('colorbox.settings');
grisendo's avatar
grisendo committed
71

72
    $form['colorbox_custom_settings'] = [
73
      '#type' => 'details',
74
      '#title' => $this->t('Styles and options'),
75
      '#open' => TRUE,
76 77
    ];
    $colorbox_styles = [
78 79 80 81 82 83 84 85 86
      'default' => $this->t('Default'),
      'plain' => $this->t('Plain (mainly for images)'),
      'stockholmsyndrome' => $this->t('Stockholm Syndrome'),
      'example1' => $this->t('Example 1'),
      'example2' => $this->t('Example 2'),
      'example3' => $this->t('Example 3'),
      'example4' => $this->t('Example 4'),
      'example5' => $this->t('Example 5'),
      'none' => $this->t('None'),
87 88
    ];
    $form['colorbox_custom_settings']['colorbox_style'] = [
grisendo's avatar
grisendo committed
89
      '#type' => 'select',
90
      '#title' => $this->t('Style'),
grisendo's avatar
grisendo committed
91 92
      '#options' => $colorbox_styles,
      '#default_value' => $config->get('custom.style'),
93
      '#description' => $this->t('Select the style to use for the Colorbox. The example styles are the ones that come with the Colorbox plugin. Select "None" if you have added Colorbox styles to your theme.  <br> <strong>Examples</strong>: <ul><li><a href="/modules/colorbox/images/admin/example_default.png" target="blank">Default</a></li><li><a href="/modules/colorbox/images/admin/example_plain.png" target="blank">Plain</a></li><li><a href="/modules/colorbox/images/admin/example_stockholm_syndrome.png" target="blank">Stockholm Syndrome</a></li><li><a href="/modules/colorbox/images/admin/colorbox_example_1.png" target="blank">Example 1</a></li><li><a href="/modules/colorbox/images/admin/colorbox_example_2.png" target="blank">Example 2</a></li><li><a href="/modules/colorbox/images/admin/colorbox_example_3.png" target="blank">Example 3</a></li><li><a href="/modules/colorbox/images/admin/colorbox_example_4.png" target="blank">Example 4</a></li><li><a href="/modules/colorbox/images/admin/example_none.png" target="blank">None</a></li></ul>'),
94 95
    ];
    $form['colorbox_custom_settings']['colorbox_custom_settings_activate'] = [
grisendo's avatar
grisendo committed
96
      '#type' => 'radios',
97
      '#title' => $this->t('Options'),
98
      '#options' => [0 => $this->t('Default'), 1 => $this->t('Custom')],
grisendo's avatar
grisendo committed
99
      '#default_value' => $config->get('custom.activate'),
100
      '#description' => $this->t('Use the default or custom options for Colorbox.'),
101 102
    ];
    $form['colorbox_custom_settings']['colorbox_transition_type'] = [
grisendo's avatar
grisendo committed
103
      '#type' => 'radios',
104
      '#title' => $this->t('Transition type'),
105
      '#options' => [
106 107 108
        'elastic' => $this->t('Elastic'),
        'fade' => $this->t('Fade'),
        'none' => $this->t('None'),
109
      ],
grisendo's avatar
grisendo committed
110
      '#default_value' => $config->get('custom.transition_type'),
111
      '#description' => $this->t('The transition type.'),
112
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
113 114
    ];
    $form['colorbox_custom_settings']['colorbox_transition_speed'] = [
grisendo's avatar
grisendo committed
115
      '#type' => 'select',
116
      '#title' => $this->t('Transition speed'),
117
      '#options' => $this->optionsRange(100, 600, 50),
grisendo's avatar
grisendo committed
118
      '#default_value' => $config->get('custom.transition_speed'),
119
      '#description' => $this->t('Sets the speed of the fade and elastic transitions, in milliseconds.'),
120
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
121 122
    ];
    $form['colorbox_custom_settings']['colorbox_opacity'] = [
grisendo's avatar
grisendo committed
123
      '#type' => 'select',
124
      '#title' => $this->t('Opacity'),
125
      '#options' => $this->optionsRange(0, 1, 0.05),
grisendo's avatar
grisendo committed
126
      '#default_value' => $config->get('custom.opacity'),
127
      '#description' => $this->t('The overlay opacity level. Range: 0 to 1.'),
128
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
129 130
    ];
    $form['colorbox_custom_settings']['colorbox_text_current'] = [
grisendo's avatar
grisendo committed
131
      '#type' => 'textfield',
132
      '#title' => $this->t('Current'),
grisendo's avatar
grisendo committed
133 134
      '#default_value' => $config->get('custom.text_current'),
      '#size' => 30,
135
      '#description' => $this->t('Text format for the content group / gallery count. {current} and {total} are detected and replaced with actual numbers while Colorbox runs.'),
136
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
137 138
    ];
    $form['colorbox_custom_settings']['colorbox_text_previous'] = [
grisendo's avatar
grisendo committed
139
      '#type' => 'textfield',
140
      '#title' => $this->t('Previous'),
grisendo's avatar
grisendo committed
141 142
      '#default_value' => $config->get('custom.text_previous'),
      '#size' => 30,
143
      '#description' => $this->t('Text for the previous button in a shared relation group.'),
144
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
145 146
    ];
    $form['colorbox_custom_settings']['colorbox_text_next'] = [
grisendo's avatar
grisendo committed
147
      '#type' => 'textfield',
148
      '#title' => $this->t('Next'),
grisendo's avatar
grisendo committed
149 150
      '#default_value' => $config->get('custom.text_next'),
      '#size' => 30,
151
      '#description' => $this->t('Text for the next button in a shared relation group.'),
152
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
153 154
    ];
    $form['colorbox_custom_settings']['colorbox_text_close'] = [
grisendo's avatar
grisendo committed
155
      '#type' => 'textfield',
156
      '#title' => $this->t('Close'),
grisendo's avatar
grisendo committed
157 158
      '#default_value' => $config->get('custom.text_close'),
      '#size' => 30,
159
      '#description' => $this->t('Text for the close button. The "Esc" key will also close Colorbox.'),
160
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
161 162
    ];
    $form['colorbox_custom_settings']['colorbox_maxwidth'] = [
grisendo's avatar
grisendo committed
163
      '#type' => 'textfield',
164
      '#title' => $this->t('Max width'),
grisendo's avatar
grisendo committed
165 166
      '#default_value' => $config->get('custom.maxwidth'),
      '#size' => 30,
167
      '#description' => $this->t('Set a maximum width for loaded content. Example: "100%", 500, "500px".'),
168
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
169 170
    ];
    $form['colorbox_custom_settings']['colorbox_maxheight'] = [
grisendo's avatar
grisendo committed
171
      '#type' => 'textfield',
172
      '#title' => $this->t('Max height'),
grisendo's avatar
grisendo committed
173 174
      '#default_value' => $config->get('custom.maxheight'),
      '#size' => 30,
175
      '#description' => $this->t('Set a maximum height for loaded content. Example: "100%", 500, "500px".'),
176
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
177 178
    ];
    $form['colorbox_custom_settings']['colorbox_initialwidth'] = [
grisendo's avatar
grisendo committed
179
      '#type' => 'textfield',
180
      '#title' => $this->t('Initial width'),
grisendo's avatar
grisendo committed
181 182
      '#default_value' => $config->get('custom.initialwidth'),
      '#size' => 30,
183
      '#description' => $this->t('Set the initial width, prior to any content being loaded. Example: "100%", 500, "500px".'),
184
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
185 186
    ];
    $form['colorbox_custom_settings']['colorbox_initialheight'] = [
grisendo's avatar
grisendo committed
187
      '#type' => 'textfield',
188
      '#title' => $this->t('Initial height'),
grisendo's avatar
grisendo committed
189 190
      '#default_value' => $config->get('custom.initialheight'),
      '#size' => 30,
191
      '#description' => $this->t('Set the initial height, prior to any content being loaded. Example: "100%", 500, "500px".'),
192
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
193 194
    ];
    $form['colorbox_custom_settings']['colorbox_overlayclose'] = [
195
      '#type' => 'checkbox',
196
      '#title' => $this->t('Overlay close'),
197
      '#default_value' => $config->get('custom.overlayclose'),
198
      '#description' => $this->t('Enable closing Colorbox by clicking on the background overlay.'),
199
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
200 201
    ];
    $form['colorbox_custom_settings']['colorbox_returnfocus'] = [
202
      '#type' => 'checkbox',
203 204 205 206
      '#title' => $this->t('Return focus'),
      '#default_value' => $config->get('custom.returnfocus'),
      '#description' => $this->t('Return focus when Colorbox exits to the element it was launched from.'),
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
207 208
    ];
    $form['colorbox_custom_settings']['colorbox_fixed'] = [
grisendo's avatar
grisendo committed
209
      '#type' => 'checkbox',
210
      '#title' => $this->t('Fixed'),
grisendo's avatar
grisendo committed
211
      '#default_value' => $config->get('custom.fixed'),
212
      '#description' => $this->t("If the Colorbox should be displayed in a fixed position within the visitor's viewport or relative to the document."),
213
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
214 215
    ];
    $form['colorbox_custom_settings']['colorbox_scrolling'] = [
216
      '#type' => 'checkbox',
217
      '#title' => $this->t('Scrollbars'),
218
      '#default_value' => $config->get('custom.scrolling'),
219
      '#description' => $this->t('If unchecked, Colorbox will hide scrollbars for overflowing content. This could be used on conjunction with the resize method for a smoother transition if you are appending content to an already open instance of Colorbox.'),
220
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
221
    ];
grisendo's avatar
grisendo committed
222

223
    $form['colorbox_custom_settings']['colorbox_slideshow_settings'] = [
224
      '#type' => 'details',
225
      '#title' => $this->t('Slideshow settings'),
grisendo's avatar
grisendo committed
226 227
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
228
      '#states' => $this->getState(static::STATE_CUSTOM_SETTINGS),
229 230
    ];
    $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_slideshow'] = [
grisendo's avatar
grisendo committed
231
      '#type' => 'radios',
232
      '#title' => $this->t('Slideshow'),
233
      '#options' => [0 => $this->t('Off'), 1 => $this->t('On')],
grisendo's avatar
grisendo committed
234
      '#default_value' => $config->get('custom.slideshow.slideshow'),
235
      '#description' => $this->t('An automatic slideshow to a content group / gallery.'),
236 237
    ];
    $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_slideshowauto'] = [
grisendo's avatar
grisendo committed
238
      '#type' => 'checkbox',
239
      '#title' => $this->t('Slideshow autostart'),
grisendo's avatar
grisendo committed
240
      '#default_value' => $config->get('custom.slideshow.auto'),
241
      '#description' => $this->t('If the slideshow should automatically start to play.'),
242
      '#states' => $this->getState(static::STATE_SLIDESHOW_ENABLED),
243 244
    ];
    $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_slideshowspeed'] = [
grisendo's avatar
grisendo committed
245
      '#type' => 'select',
246
      '#title' => $this->t('Slideshow speed'),
247
      '#options' => $this->optionsRange(1000, 6000, 500),
grisendo's avatar
grisendo committed
248
      '#default_value' => $config->get('custom.slideshow.speed'),
249
      '#description' => $this->t('Sets the speed of the slideshow, in milliseconds.'),
250
      '#states' => $this->getState(static::STATE_SLIDESHOW_ENABLED),
251 252
    ];
    $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_text_start'] = [
grisendo's avatar
grisendo committed
253
      '#type' => 'textfield',
254
      '#title' => $this->t('Start slideshow'),
grisendo's avatar
grisendo committed
255 256
      '#default_value' => $config->get('custom.slideshow.text_start'),
      '#size' => 30,
257
      '#description' => $this->t('Text for the slideshow start button.'),
258
      '#states' => $this->getState(static::STATE_SLIDESHOW_ENABLED),
259 260
    ];
    $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_text_stop'] = [
grisendo's avatar
grisendo committed
261
      '#type' => 'textfield',
262
      '#title' => $this->t('Stop slideshow'),
grisendo's avatar
grisendo committed
263 264
      '#default_value' => $config->get('custom.slideshow.text_stop'),
      '#size' => 30,
265
      '#description' => $this->t('Text for the slideshow stop button.'),
266
      '#states' => $this->getState(static::STATE_SLIDESHOW_ENABLED),
267
    ];
grisendo's avatar
grisendo committed
268

269
    $form['colorbox_advanced_settings'] = [
270
      '#type' => 'details',
271
      '#title' => $this->t('Advanced settings'),
272 273
    ];
    $form['colorbox_advanced_settings']['colorbox_unique_token'] = [
274
      '#type' => 'radios',
275
      '#title' => $this->t('Unique per-request gallery token'),
276
      '#options' => [1 => $this->t('On'), 0 => $this->t('Off')],
277
      '#default_value' => $config->get('advanced.unique_token'),
278
      '#description' => $this->t('If On (default), Colorbox will add a unique per-request token to the gallery id to avoid images being added manually to galleries. The token was added as a security fix but some see the old behavoiur as an feature and this settings makes it possible to remove the token.'),
279 280
    ];
    $form['colorbox_advanced_settings']['colorbox_mobile_detect'] = [
grisendo's avatar
grisendo committed
281
      '#type' => 'radios',
282
      '#title' => $this->t('Mobile detection'),
283
      '#options' => [1 => $this->t('On'), 0 => $this->t('Off')],
grisendo's avatar
grisendo committed
284
      '#default_value' => $config->get('advanced.mobile_detect'),
285
      '#description' => $this->t('If on (default) Colorbox will not be active for devices with the max width set below.'),
286 287
    ];
    $form['colorbox_advanced_settings']['colorbox_mobile_device_width'] = [
grisendo's avatar
grisendo committed
288
      '#type' => 'textfield',
289
      '#title' => $this->t('Device width'),
grisendo's avatar
grisendo committed
290 291
      '#default_value' => $config->get('advanced.mobile_device_width'),
      '#size' => 30,
292
      '#description' => $this->t('Set the mobile device max width. Default: 480px.'),
293 294 295 296 297 298 299
      '#states' => [
        'visible' => [
          ':input[name="colorbox_mobile_detect"]' => ['value' => '1'],
        ],
      ],
    ];
    $form['colorbox_advanced_settings']['colorbox_caption_trim'] = [
grisendo's avatar
grisendo committed
300
      '#type' => 'radios',
301
      '#title' => $this->t('Caption shortening'),
302
      '#options' => [0 => $this->t('Default'), 1 => $this->t('Yes')],
grisendo's avatar
grisendo committed
303
      '#default_value' => $config->get('advanced.caption_trim'),
304
      '#description' => $this->t('If the caption should be made shorter in the Colorbox to avoid layout problems. The default is to shorten for the example styles, they need it, but not for other styles.'),
305 306
    ];
    $form['colorbox_advanced_settings']['colorbox_caption_trim_length'] = [
grisendo's avatar
grisendo committed
307
      '#type' => 'select',
308
      '#title' => $this->t('Caption max length'),
309
      '#options' => $this->optionsRange(40, 120, 5),
grisendo's avatar
grisendo committed
310
      '#default_value' => $config->get('advanced.caption_trim_length'),
311 312 313 314 315 316 317
      '#states' => [
        'visible' => [
          ':input[name="colorbox_caption_trim"]' => ['value' => '1'],
        ],
      ],
    ];
    $form['colorbox_advanced_settings']['colorbox_compression_type'] = [
grisendo's avatar
grisendo committed
318
      '#type' => 'radios',
319
      '#title' => $this->t('Choose Colorbox compression level'),
320
      '#options' => [
321 322
        'minified' => $this->t('Production (Minified)'),
        'source' => $this->t('Development (Uncompressed Code)'),
323
      ],
grisendo's avatar
grisendo committed
324
      '#default_value' => $config->get('advanced.compression_type'),
325
    ];
grisendo's avatar
grisendo committed
326

327
    if (!$this->moduleHandler->moduleExists('colorbox_load') || !$this->moduleHandler->moduleExists('colorbox_inline')) {
328

329 330 331 332 333 334 335 336 337 338 339 340
      $form['colorbox_extras'] = [
        '#type' => 'details',
        '#title' => $this->t('Extras'),
      ];

      $form['colorbox_extras']['colorbox_additional_tips'] = [
        '#markup' => $this->t('You can find new features in the <a href="@url_colorbox_load" target="blank">Colorbox Load</a> and <a href="@url_colorbox_inline" target="blank">Colorbox Inline</a>', [
          '@url_colorbox_load' => 'https://www.drupal.org/project/colorbox_load',
          '@url_colorbox_inline' => 'https://www.drupal.org/project/colorbox_inline',
        ]),
      ];
    }
341

grisendo's avatar
grisendo committed
342 343 344 345 346 347
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
348
  public function submitForm(array &$form, FormStateInterface $form_state) {
grisendo's avatar
grisendo committed
349

350
    $config = $this->configFactory->getEditable('colorbox.settings');
grisendo's avatar
grisendo committed
351 352

    $config
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
      ->set('custom.style', $form_state->getValue('colorbox_style'))
      ->set('custom.activate', $form_state->getValue('colorbox_custom_settings_activate'))
      ->set('custom.transition_type', $form_state->getValue('colorbox_transition_type'))
      ->set('custom.transition_speed', $form_state->getValue('colorbox_transition_speed'))
      ->set('custom.opacity', $form_state->getValue('colorbox_opacity'))
      ->set('custom.text_current', $form_state->getValue('colorbox_text_current'))
      ->set('custom.text_previous', $form_state->getValue('colorbox_text_previous'))
      ->set('custom.text_next', $form_state->getValue('colorbox_text_next'))
      ->set('custom.text_close', $form_state->getValue('colorbox_text_close'))
      ->set('custom.overlayclose', $form_state->getValue('colorbox_overlayclose'))
      ->set('custom.returnfocus', $form_state->getValue('colorbox_returnfocus'))
      ->set('custom.maxwidth', $form_state->getValue('colorbox_maxwidth'))
      ->set('custom.maxheight', $form_state->getValue('colorbox_maxheight'))
      ->set('custom.initialwidth', $form_state->getValue('colorbox_initialwidth'))
      ->set('custom.initialheight', $form_state->getValue('colorbox_initialheight'))
      ->set('custom.fixed', $form_state->getValue('colorbox_fixed'))
      ->set('custom.scrolling', $form_state->getValue('colorbox_scrolling'))
      ->set('custom.slideshow.slideshow', $form_state->getValue('colorbox_slideshow'))
      ->set('custom.slideshow.auto', $form_state->getValue('colorbox_slideshowauto'))
      ->set('custom.slideshow.speed', $form_state->getValue('colorbox_slideshowspeed'))
      ->set('custom.slideshow.text_start', $form_state->getValue('colorbox_text_start'))
      ->set('custom.slideshow.text_stop', $form_state->getValue('colorbox_text_stop'))
      ->set('advanced.unique_token', $form_state->getValue('colorbox_unique_token'))
      ->set('advanced.mobile_detect', $form_state->getValue('colorbox_mobile_detect'))
      ->set('advanced.mobile_device_width', $form_state->getValue('colorbox_mobile_device_width'))
      ->set('advanced.caption_trim', $form_state->getValue('colorbox_caption_trim'))
      ->set('advanced.caption_trim_length', $form_state->getValue('colorbox_caption_trim_length'))
      ->set('advanced.compression_type', $form_state->getValue('colorbox_compression_type'));
grisendo's avatar
grisendo committed
381

382 383
    if ($form_state->getValue('colorbox_image_style')) {
      $config->set('insert.image_style', $form_state->getValue('colorbox_image_style'));
grisendo's avatar
grisendo committed
384 385
    }

386 387
    if ($form_state->getValue('colorbox_insert_gallery')) {
      $config->set('insert.insert_gallery', $form_state->getValue('colorbox_insert_gallery'));
grisendo's avatar
grisendo committed
388 389 390 391 392 393 394
    }

    $config->save();

    parent::submitForm($form, $form_state);
  }

395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
  /**
   * Get one of the pre-defined states used in this form.
   *
   * @param string $state
   *   The state to get that matches one of the state class constants.
   *
   * @return array
   *   A corresponding form API state.
   */
  protected function getState($state) {
    $states = [
      static::STATE_CUSTOM_SETTINGS => [
        'visible' => [
          ':input[name="colorbox_custom_settings_activate"]' => ['value' => '1'],
        ],
      ],
      static::STATE_SLIDESHOW_ENABLED => [
        'visible' => [
413
          ':input[name="colorbox_slideshow"]' => ['value' => '1'],
414 415 416 417 418 419
        ],
      ],
    ];
    return $states[$state];
  }

420 421 422
  /**
   * Create a range for a series of options.
   *
423
   * @param int $start
424
   *   The start of the range.
425
   * @param int $end
426
   *   The end of the range.
427
   * @param int $step
428 429 430 431 432 433 434 435 436 437
   *   The interval between elements.
   *
   * @return array
   *   An options array for the given range.
   */
  protected function optionsRange($start, $end, $step) {
    $range = range($start, $end, $step);
    return array_combine($range, $range);
  }

grisendo's avatar
grisendo committed
438
}