Skip to content
Snippets Groups Projects
Commit 226c686a authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-4053: completing code review changes for custom layouts

parent 7854218d
No related branches found
No related tags found
No related merge requests found
...@@ -3,28 +3,11 @@ ...@@ -3,28 +3,11 @@
namespace Drupal\uw_cfg_common\Plugin\Layout; namespace Drupal\uw_cfg_common\Plugin\Layout;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Layout\LayoutDefault;
use Drupal\Core\Plugin\PluginFormInterface;
/** /**
* A UW two column layout. * A UW two column layout.
*
* @Layout(
* id = "uw_two_column",
* label = @Translation("Two columns"),
* category = @Translation("UW layouts"),
* template = "templates/layout/layout--uwtwocol",
* regions = {
* "first" = {
* "label" = @Translation("Column 1"),
* },
* "second" = {
* "label" = @Translation("Column 2"),
* },
* }
* )
*/ */
class UwTwoColumnLayout extends LayoutDefault implements PluginFormInterface { class Uw2ColumnLayout extends UwColumnLayoutBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
...@@ -51,31 +34,4 @@ class UwTwoColumnLayout extends LayoutDefault implements PluginFormInterface { ...@@ -51,31 +34,4 @@ class UwTwoColumnLayout extends LayoutDefault implements PluginFormInterface {
return $form; return $form;
} }
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// Set the column class in the config.
$this->configuration['column_class'] = $form_state->getValue(['layout_settings', 'column_class'], NULL);
}
/**
* {@inheritdoc}
*/
public function build(array $regions) {
// Build the render array as usual.
$build = parent::build($regions);
// Retrieve the config for the layout.
$configuration = $this->getConfiguration();
// Set the column class to be used in the layout template.
$build['#settings']['column_class'] = $configuration['column_class'];
return $build;
}
} }
...@@ -3,31 +3,11 @@ ...@@ -3,31 +3,11 @@
namespace Drupal\uw_cfg_common\Plugin\Layout; namespace Drupal\uw_cfg_common\Plugin\Layout;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Layout\LayoutDefault;
use Drupal\Core\Plugin\PluginFormInterface;
/** /**
* A UW three column layout. * A UW three column layout.
*
* @Layout(
* id = "uw_three_column",
* label = @Translation("Three columns"),
* category = @Translation("UW layouts"),
* template = "templates/layout/layout--uwthreecol",
* regions = {
* "first" = {
* "label" = @Translation("Column 1"),
* },
* "second" = {
* "label" = @Translation("Column 2"),
* },
* "third" = {
* "label" = @Translation("Column 3"),
* },
* }
* )
*/ */
class UwThreeColumnLayout extends LayoutDefault implements PluginFormInterface { class Uw3ColumnLayout extends UwColumnLayoutBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
...@@ -57,31 +37,4 @@ class UwThreeColumnLayout extends LayoutDefault implements PluginFormInterface { ...@@ -57,31 +37,4 @@ class UwThreeColumnLayout extends LayoutDefault implements PluginFormInterface {
return $form; return $form;
} }
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// Set the column class in the config.
$this->configuration['column_class'] = $form_state->getValue(['layout_settings', 'column_class'], NULL);
}
/**
* {@inheritdoc}
*/
public function build(array $regions) {
// Build the render array as usual.
$build = parent::build($regions);
// Retrieve the config for the layout.
$configuration = $this->getConfiguration();
// Set the column class to be used in the layout template.
$build['#settings']['column_class'] = $configuration['column_class'];
return $build;
}
} }
...@@ -3,34 +3,11 @@ ...@@ -3,34 +3,11 @@
namespace Drupal\uw_cfg_common\Plugin\Layout; namespace Drupal\uw_cfg_common\Plugin\Layout;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Layout\LayoutDefault;
use Drupal\Core\Plugin\PluginFormInterface;
/** /**
* A UW four column layout. * A UW four column layout.
*
* @Layout(
* id = "uw_four_column",
* label = @Translation("Four columns"),
* category = @Translation("UW layouts"),
* template = "templates/layout/layout--uwfourcol",
* regions = {
* "first" = {
* "label" = @Translation("Column 1"),
* },
* "second" = {
* "label" = @Translation("Column 2"),
* },
* "third" = {
* "label" = @Translation("Column 3"),
* },
* "four" = {
* "label" = @Translation("Column 4"),
* },
* }
* )
*/ */
class UwFourColumnLayout extends LayoutDefault implements PluginFormInterface { class Uw4ColumnLayout extends UwColumnLayoutBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
...@@ -60,31 +37,4 @@ class UwFourColumnLayout extends LayoutDefault implements PluginFormInterface { ...@@ -60,31 +37,4 @@ class UwFourColumnLayout extends LayoutDefault implements PluginFormInterface {
return $form; return $form;
} }
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// Set the column class in the config.
$this->configuration['column_class'] = $form_state->getValue(['layout_settings', 'column_class'], NULL);
}
/**
* {@inheritdoc}
*/
public function build(array $regions) {
// Build the render array as usual.
$build = parent::build($regions);
// Retrieve the config for the layout.
$configuration = $this->getConfiguration();
// Set the column class to be used in the layout template.
$build['#settings']['column_class'] = $configuration['column_class'];
return $build;
}
} }
...@@ -3,37 +3,11 @@ ...@@ -3,37 +3,11 @@
namespace Drupal\uw_cfg_common\Plugin\Layout; namespace Drupal\uw_cfg_common\Plugin\Layout;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Layout\LayoutDefault;
use Drupal\Core\Plugin\PluginFormInterface;
/** /**
* A UW four column layout. * A UW four column layout.
*
* @Layout(
* id = "uw_five_column",
* label = @Translation("Five columns"),
* category = @Translation("UW layouts"),
* template = "templates/layout/layout--uwfivecol",
* regions = {
* "first" = {
* "label" = @Translation("Column 1"),
* },
* "second" = {
* "label" = @Translation("Column 2"),
* },
* "third" = {
* "label" = @Translation("Column 3"),
* },
* "fourth" = {
* "label" = @Translation("Column 4"),
* },
* "fifth" = {
* "label" = @Translation("Column 5"),
* },
* }
* )
*/ */
class UwFiveColumnLayout extends LayoutDefault implements PluginFormInterface { class Uw5ColumnLayout extends UwColumnLayoutBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
...@@ -65,30 +39,4 @@ class UwFiveColumnLayout extends LayoutDefault implements PluginFormInterface { ...@@ -65,30 +39,4 @@ class UwFiveColumnLayout extends LayoutDefault implements PluginFormInterface {
return $form; return $form;
} }
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// Set the column class in the config.
$this->configuration['column_class'] = $form_state->getValue(['layout_settings', 'column_class'], NULL);
}
/**
* {@inheritdoc}
*/
public function build(array $regions) {
// Build the render array as usual.
$build = parent::build($regions);
// Retrieve the config for the layout.
$configuration = $this->getConfiguration();
// Set the column class to be used in the layout template.
$build['#settings']['column_class'] = $configuration['column_class'];
return $build;
}
} }
<?php <?php
namespace Drupal\uw_cfg_common\Plugin\Layout; namespace Drupal\uw_cfg_common\Plugin\Layout;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Layout\LayoutDefault; use Drupal\Core\Layout\LayoutDefault;
use Drupal\Core\Plugin\PluginFormInterface; use Drupal\Core\Plugin\PluginFormInterface;
/** /**
* A UW one column layout. * A column layout base.
* */
* @Layout( class UwColumnLayoutBase extends LayoutDefault implements PluginFormInterface {
* id = "uw_one_column",
* label = @Translation("One column"), /**
* category = @Translation("UW layouts"), * {@inheritdoc}
* template = "templates/layout/layout--uwonecol", */
* regions = { public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
* "first" = {
* "label" = @Translation("Column 1"), // Set the column class in the config.
* }, $this->configuration['column_class'] = $form_state->getValue(['layout_settings', 'column_class'], NULL);
* } }
* )
*/ /**
class UwOneColumnLayout extends LayoutDefault implements PluginFormInterface { * {@inheritdoc}
*/
/** public function build(array $regions) {
* {@inheritdoc}
*/ // Build the render array as usual.
public function build(array $regions) { $build = parent::build($regions);
// Build the render array as usual. // Retrieve the config for the layout.
$build = parent::build($regions); $configuration = $this->getConfiguration();
return $build; // Set the column class to be used in the layout template.
} $build['#settings']['column_class'] = $configuration['column_class'];
} return $build;
}
}
uw_one_column: uw_one_column:
label: 'One column' label: 'One column'
category: 'UW layouts' category: 'UW layouts'
class: '\Drupal\uw_cfg_common\Plugin\Layout\UwOneColumnLayout' template: uw_fdsu_theme_resp/templates/layout/layout--uw1col
template: uw_fdsu_theme_resp/templates/layout/layout--uwonecol
default_region: first default_region: first
regions: regions:
first: first:
...@@ -12,27 +11,27 @@ uw_one_column: ...@@ -12,27 +11,27 @@ uw_one_column:
uw_two_column: uw_two_column:
label: 'Two columns' label: 'Two columns'
category: 'UW layouts' category: 'UW layouts'
class: '\Drupal\uw_cfg_common\Plugin\Layout\UwTwoColumnLayout' class: '\Drupal\uw_cfg_common\Plugin\Layout\Uw2ColumnLayout'
template: uw_fdsu_theme_resp/templates/layout/layout--uwtwocol template: uw_fdsu_theme_resp/templates/layout/layout--uw2col
default_region: first default_region: first
regions: regions:
first: first:
label: One label: First
second: second:
label: Two label: Second
icon_map: icon_map:
- [first, second] - [first, second]
uw_three_column: uw_three_column:
label: 'Three columns' label: 'Three columns'
category: 'UW layouts' category: 'UW layouts'
class: '\Drupal\uw_cfg_common\Plugin\Layout\UwThreeColumnLayout' class: '\Drupal\uw_cfg_common\Plugin\Layout\Uw3ColumnLayout'
template: uw_fdsu_theme_resp/templates/layout/layout--uwthreecol template: uw_fdsu_theme_resp/templates/layout/layout--uw3col
default_region: first default_region: first
regions: regions:
first: first:
label: One label: First
second: second:
label: Two label: Second
third: third:
label: Third label: Third
icon_map: icon_map:
...@@ -40,14 +39,14 @@ uw_three_column: ...@@ -40,14 +39,14 @@ uw_three_column:
uw_four_column: uw_four_column:
label: 'Four columns' label: 'Four columns'
category: 'UW layouts' category: 'UW layouts'
class: '\Drupal\uw_cfg_common\Plugin\Layout\UwFourColumnLayout' class: '\Drupal\uw_cfg_common\Plugin\Layout\Uw4ColumnLayout'
template: uw_fdsu_theme_resp/templates/layout/layout--uwfourcol template: uw_fdsu_theme_resp/templates/layout/layout--uw4col
default_region: first default_region: first
regions: regions:
first: first:
label: One label: First
second: second:
label: Two label: Second
third: third:
label: Third label: Third
fourth: fourth:
...@@ -57,14 +56,14 @@ uw_four_column: ...@@ -57,14 +56,14 @@ uw_four_column:
uw_five_column: uw_five_column:
label: 'Five columns' label: 'Five columns'
category: 'UW layouts' category: 'UW layouts'
class: '\Drupal\uw_cfg_common\Plugin\Layout\UwFiveColumnLayout' class: '\Drupal\uw_cfg_common\Plugin\Layout\Uw5ColumnLayout'
template: uw_fdsu_theme_resp/templates/layout/layout--uwfivecol template: uw_fdsu_theme_resp/templates/layout/layout--uw5col
default_region: first default_region: first
regions: regions:
first: first:
label: One label: First
second: second:
label: Two label: Second
third: third:
label: Third label: Third
fourth: fourth:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment