You are here

GridStackStylizerPluginBase.php in GridStack 8.2

Namespace

Drupal\gridstack

File

src/GridStackStylizerPluginBase.php
View source
<?php

namespace Drupal\gridstack;

use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Provides base class for all gridstack styles.
 */
abstract class GridStackStylizerPluginBase extends GridStackPluginBase implements GridStackStylizerPluginInterface {

  /**
   * The blazy entity service to support Media Library at Layout Builder pages.
   *
   * @var \Drupal\blazy\BlazyEntityInterface
   */
  protected $blazyEntity;

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
    $instance->blazyEntity = $container
      ->get('blazy.entity');
    return $instance;
  }

  /**
   * Provides gridstack skins and libraries.
   */
  public function attach(array &$load, array $attach = []) {

    // Do nothing.
  }

  /**
   * {@inheritdoc}
   */
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {

    // Do nothing.
  }

  /**
   * Returns unique variant ID.
   */
  protected function getVariantUniqueId($optionset) {
    return $optionset
      ->id() . '__' . $optionset
      ->randomize();
  }

}

Classes

Namesort descending Description
GridStackStylizerPluginBase Provides base class for all gridstack styles.