You are here

protected function BlazyStyleBaseTrait::buildSettings in Blazy 8.2

Same name and namespace in other branches
  1. 8 src/Dejavu/BlazyStyleBaseTrait.php \Drupal\blazy\Dejavu\BlazyStyleBaseTrait::buildSettings()
  2. 7 src/Dejavu/BlazyStyleBaseTrait.php \Drupal\blazy\Dejavu\BlazyStyleBaseTrait::buildSettings()

Provides commons settings for the style plugins.

2 calls to BlazyStyleBaseTrait::buildSettings()
BlazyViews::render in src/Plugin/views/style/BlazyViews.php
Overrides StylePluginBase::render().
BlazyViewsTest::render in tests/modules/blazy_test/src/Plugin/views/style/BlazyViewsTest.php
Overrides StylePluginBase::render().

File

src/Dejavu/BlazyStyleBaseTrait.php, line 53

Class

BlazyStyleBaseTrait
A Trait common for optional views style plugins.

Namespace

Drupal\blazy\Dejavu

Code

protected function buildSettings() {
  $view = $this->view;
  $count = count($view->result);
  $settings = $this->options;
  $view_name = $view->storage
    ->id();
  $view_mode = $view->current_display;
  $plugin_id = $this
    ->getPluginId();
  $instance = str_replace('_', '-', "{$view_name}-{$view_mode}");
  $id = empty($settings['id']) ? '' : $settings['id'];
  $id = Blazy::getHtmlId("{$plugin_id}-views-{$instance}", $id);
  $settings += [
    'cache_metadata' => [
      'keys' => [
        $id,
        $view_mode,
        $count,
      ],
    ],
  ] + BlazyDefault::lazySettings();
  $this
    ->prepareSettings($settings);

  // Prepare needed settings to work with.
  $settings['check_blazy'] = TRUE;
  $settings['id'] = $id;
  $settings['cache_tags'] = $view
    ->getCacheTags();
  $settings['count'] = $count;
  $settings['current_view_mode'] = $view_mode;
  $settings['instance_id'] = $instance;
  $settings['multiple'] = TRUE;
  $settings['plugin_id'] = $settings['view_plugin_id'] = $plugin_id;
  $settings['use_ajax'] = $view
    ->ajaxEnabled();
  $settings['view_name'] = $view_name;
  $settings['view_display'] = $view->style_plugin->displayHandler
    ->getPluginId();
  $settings['_views'] = TRUE;
  if (!empty($this->htmlSettings)) {
    $settings = NestedArray::mergeDeep($settings, $this->htmlSettings);
  }
  $this
    ->blazyManager()
    ->getCommonSettings($settings);
  $this
    ->blazyManager()
    ->getModuleHandler()
    ->alter('blazy_settings_views', $settings, $view);
  return $settings;
}