You are here

public function SlickListBuilder::list_render in Slick Carousel 7.3

File

slick_ui/src/Controller/SlickListBuilder.php, line 88

Class

SlickListBuilder
Provides a listing of Slick optionsets.

Namespace

Drupal\slick_ui\Controller

Code

public function list_render(&$form_state) {
  $build['parent'] = [
    '#markup' => parent::list_render($form_state),
  ];
  $availaible_skins = [];
  $skins = $this->manager
    ->getSkins()['skins'];
  foreach ($skins as $key => $skin) {
    $name = isset($skin['name']) ? $skin['name'] : $key;
    $group = isset($skin['group']) ? check_plain($skin['group']) : 'None';
    $provider = isset($skin['provider']) ? check_plain($skin['provider']) : 'Lory';
    $description = isset($skin['description']) ? check_plain($skin['description']) : t('No description');
    $markup = '<h3>' . t('@skin <br><small>Id: @id | Group: @group | Provider: @provider</small>', [
      '@skin' => $name,
      '@id' => $key,
      '@group' => $group,
      '@provider' => $provider,
    ]) . '</h3>';
    $markup .= '<p><em>&mdash; ' . $description . '</em></p>';
    $availaible_skins[$key] = [
      '#markup' => '<div class="messages status">' . $markup . '</div>',
    ];
  }
  ksort($availaible_skins);
  $availaible_skins = [
    'default' => $availaible_skins['default'],
  ] + $availaible_skins;
  $settings['grid'] = 3;
  $settings['grid_medium'] = 2;
  $settings['blazy'] = FALSE;
  $settings['style'] = 'column';
  $header = '<br><hr><h2>' . t('Available skins') . '</h2>';
  $header .= '<p>' . t('Some skin works best with a specific Optionset, and vice versa. Use matching names if found. Else happy adventure!') . '</p>';
  $build['skins_header']['#markup'] = $header;
  $build['skins_header']['#weight'] = 20;
  $build['skins'] = BlazyGrid::build($availaible_skins, $settings);
  $build['skins']['#weight'] = 21;
  $build['skins']['#attached'] = $this->manager
    ->attach($settings);
  $build['skins']['#attached']['library'][] = [
    'blazy',
    'admin',
  ];
  return drupal_render_children($build);
}