SectionLayout.php in Dashboards with Layout Builder 8        
                          
                  
                        
  
  
  
  
File
  src/Layouts/SectionLayout.php
  
    View source  
  <?php
namespace Drupal\dashboards\Layouts;
use Drupal\Core\Layout\LayoutDefault;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginFormInterface;
class SectionLayout extends LayoutDefault implements PluginFormInterface {
  
  public function defaultConfiguration() {
    return parent::defaultConfiguration() + [
      'reverse' => FALSE,
    ];
  }
  
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $configuration = $this
      ->getConfiguration();
    $form['reverse'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Reverse columns'),
      '#default_value' => $configuration['reverse'],
    ];
    return $form;
  }
  
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    $this->configuration['reverse'] = $form_state
      ->getValue('reverse');
  }
  
  public function build(array $regions) {
    $configuration = $this
      ->getConfiguration();
    $build = parent::build($regions);
    if ($configuration['reverse']) {
      $build['#attributes']['class'][] = 'dashboard-reverse';
    }
    return $build;
  }
}