Skip to content

Instantly share code, notes, and snippets.

@johndevman
Last active June 19, 2018 13:07
Show Gist options
  • Save johndevman/16ea1f0637ac69410725dd42a4a1a4c2 to your computer and use it in GitHub Desktop.
Save johndevman/16ea1f0637ac69410725dd42a4a1a4c2 to your computer and use it in GitHub Desktop.
Configurable layout plugin
example_image:
label: 'Image'
class: '\Drupal\example\Plugin\Layout\LayoutDefaultConfig'
path: layouts/example--image
template: example--image
category: 'Columns: 1'
icon: icon-image.svg
<?php
namespace Drupal\example\Plugin\Layout;
use Drupal\Core\Layout\LayoutDefault;
use Drupal\Core\Plugin\PluginFormInterface;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides a default class for configurable Layout plugins.
*/
class LayoutDefaultConfig extends LayoutDefault implements PluginFormInterface {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return $form;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment