layout_builder_tomsaw-1.0.x-dev/src/LayoutBuilderTomSawCallback.php

src/LayoutBuilderTomSawCallback.php
<?php

declare(strict_types=1);

namespace Drupal\layout_builder_tomsaw;

use Drupal\Core\Form\FormStateInterface;

class LayoutBuilderTomSawCallback {
  private const WEIGHTS = [
    'block_start' => -50,
    'block' => -49,
    'block_end' => -48,
    'inline_start' => -47,
    'inline' => -46,
    'inline_end' => -45,
    'container' => -40,
    'heading' => -30,
    'text' => -29,
    'color' => -20,
    'background' => -19,
  ];
  public static function sortUiStyleCategories(array &$element, FormStateInterface $formState): array
  {
    foreach (self::WEIGHTS as $key => $weight)
      if (isset($element['wrapper'][$key]))
        $element['wrapper'][$key]['#weight'] = $weight;

    return $element;
  }

  public static function blockPlugin_submit(array $form, FormStateInterface $form_state): void {
    $form_object = $form_state->getFormObject();
    assert($form_object instanceof \Drupal\layout_builder\Form\ConfigureBlockFormBase);
    $component = $form_object->getCurrentComponent();
  
    $component->set('object_fit', $form_state->getValue('settings')['object_fit']);
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc