You are here

class MixitupViewsDefaultOptionsService in MixItUp Views 8

Same name and namespace in other branches
  1. 8.2 src/MixitupViewsDefaultOptionsService.php \Drupal\mixitup_views\MixitupViewsDefaultOptionsService

Class MixitupViewsDefaultOptions.

@package Drupal\mixitup_views

Hierarchy

Expanded class hierarchy of MixitupViewsDefaultOptionsService

3 files declare their use of MixitupViewsDefaultOptionsService
MixItUpDefaultOptionsServiceTest.php in tests/src/Unit/MixItUpDefaultOptionsServiceTest.php
MixitUpFiltersFormTest.php in tests/src/Kernel/MixitUpFiltersFormTest.php
MixItUpFuncTest.php in tests/src/Kernel/MixItUpFuncTest.php
1 string reference to 'MixitupViewsDefaultOptionsService'
mixitup_views.services.yml in ./mixitup_views.services.yml
mixitup_views.services.yml
1 service uses MixitupViewsDefaultOptionsService
mixitup_views.default_options_service in ./mixitup_views.services.yml
Drupal\mixitup_views\MixitupViewsDefaultOptionsService

File

src/MixitupViewsDefaultOptionsService.php, line 10

Namespace

Drupal\mixitup_views
View source
class MixitupViewsDefaultOptionsService {

  /**
   * Get default option for mixitup js.
   *
   * @return array
   *   Array of default mixitup params.
   */
  public function defaultOptions($convert = FALSE) {
    $options = [
      'selectors' => [
        'target' => '.mix',
        'filter' => '.filter',
        'sort' => '.sort',
      ],
      'load' => [
        'filter' => 'all',
        'sort' => 'default:asc',
      ],
      'animation' => [
        'enable' => TRUE,
        'effects' => 'fade scale',
        'duration' => 600,
        'easing' => 'ease',
        'perspectiveDistance' => '3000px',
        'perspectiveOrigin' => '50% 50%',
        'queue' => TRUE,
        'queueLimit' => 1,
      ],
      'restrict' => [
        'vocab' => FALSE,
        'vocab_ids' => [],
      ],
    ];
    if ($convert) {
      $options = $this
        ->convertFromMixitupOptions($options);
    }
    return $options;
  }

  /**
   * Convert mixitup options array to needed.
   *
   * @param array $mixitup_options
   *   Options array in mixitup js style.
   *
   * @return array
   *   Converted array of mixitup params.
   */
  public function convertFromMixitupOptions(array $mixitup_options) {
    $converted_options = [];
    foreach ($mixitup_options as $cat => $options) {
      foreach ($options as $option => $default_value) {
        $converted_options[$cat . '_' . $option] = $default_value;
      }
    }
    return $converted_options;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MixitupViewsDefaultOptionsService::convertFromMixitupOptions public function Convert mixitup options array to needed.
MixitupViewsDefaultOptionsService::defaultOptions public function Get default option for mixitup js.