Skip to content
Snippets Groups Projects
Commit 31a365eb authored by Liam Morland's avatar Liam Morland
Browse files

Issue #3194285: Convert some methods to static

parent 727eca94
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,6 @@ namespace Drupal\layout_builder_ids\EventSubscriber; ...@@ -5,7 +5,6 @@ namespace Drupal\layout_builder_ids\EventSubscriber;
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\core_event_dispatcher\Event\Form\FormAlterEvent; use Drupal\core_event_dispatcher\Event\Form\FormAlterEvent;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;
use Drupal\layout_builder_ids\Service\LayoutBuilderIdsService; use Drupal\layout_builder_ids\Service\LayoutBuilderIdsService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
...@@ -15,8 +14,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; ...@@ -15,8 +14,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
*/ */
class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface { class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface {
use StringTranslationTrait;
/** /**
* Layout builder ids service. * Layout builder ids service.
* *
...@@ -40,7 +37,7 @@ class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface { ...@@ -40,7 +37,7 @@ class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface {
* @param \Drupal\core_event_dispatcher\Event\Form\FormAlterEvent $event * @param \Drupal\core_event_dispatcher\Event\Form\FormAlterEvent $event
* The event. * The event.
*/ */
public function alterForm(FormAlterEvent $event): void { public static function alterForm(FormAlterEvent $event): void {
// Get the form from the event. // Get the form from the event.
$form = &$event->getForm(); $form = &$event->getForm();
...@@ -63,7 +60,7 @@ class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface { ...@@ -63,7 +60,7 @@ class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface {
'#title' => 'Block ID', '#title' => 'Block ID',
'#weight' => 99, '#weight' => 99,
'#default_value' => $layout_builder_id ?: NULL, '#default_value' => $layout_builder_id ?: NULL,
'#description' => $this->t('Block ID is an optional setting which is used to support an anchor link to this block. For example, entering "feature" lets you link directly to this block by adding "#feature" to the end of the URL.</br>IDs should start with a letter, may only contain letters, numbers, underscores, hyphens, and periods, and should be unique on the page.'), '#description' => t('Block ID is an optional setting which is used to support an anchor link to this block. For example, entering "feature" lets you link directly to this block by adding "#feature" to the end of the URL.</br>IDs should start with a letter, may only contain letters, numbers, underscores, hyphens, and periods, and should be unique on the page.'),
]; ];
// Add the form validation for configure block. // Add the form validation for configure block.
...@@ -80,7 +77,7 @@ class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface { ...@@ -80,7 +77,7 @@ class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function layoutBuilderIdsConfigureBlockFormValidation(array &$form, FormStateInterface $form_state) { public static function layoutBuilderIdsConfigureBlockFormValidation(array &$form, FormStateInterface $form_state) {
// Get the layout builder id from the form, // Get the layout builder id from the form,
// also put the id through the HTML getId to make sure // also put the id through the HTML getId to make sure
...@@ -111,7 +108,7 @@ class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface { ...@@ -111,7 +108,7 @@ class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function layoutBuilderIdsConfigureBlockSubmitForm(array &$form, FormStateInterface $form_state) { public static function layoutBuilderIdsConfigureBlockSubmitForm(array &$form, FormStateInterface $form_state) {
// Load in the layout_builder_id. // Load in the layout_builder_id.
$layout_builder_id = $form_state->getValue(['settings', 'layout_builder_id']); $layout_builder_id = $form_state->getValue(['settings', 'layout_builder_id']);
......
...@@ -5,7 +5,6 @@ namespace Drupal\layout_builder_ids\EventSubscriber; ...@@ -5,7 +5,6 @@ namespace Drupal\layout_builder_ids\EventSubscriber;
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\core_event_dispatcher\Event\Form\FormAlterEvent; use Drupal\core_event_dispatcher\Event\Form\FormAlterEvent;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;
use Drupal\layout_builder_ids\Service\LayoutBuilderIdsService; use Drupal\layout_builder_ids\Service\LayoutBuilderIdsService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
...@@ -15,8 +14,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; ...@@ -15,8 +14,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
*/ */
class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface { class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface {
use StringTranslationTrait;
/** /**
* Layout builder ids service. * Layout builder ids service.
* *
...@@ -40,7 +37,7 @@ class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface { ...@@ -40,7 +37,7 @@ class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface {
* @param \Drupal\core_event_dispatcher\Event\Form\FormAlterEvent $event * @param \Drupal\core_event_dispatcher\Event\Form\FormAlterEvent $event
* The event. * The event.
*/ */
public function alterForm(FormAlterEvent $event): void { public static function alterForm(FormAlterEvent $event): void {
// Get the form from the event. // Get the form from the event.
$form = &$event->getForm(); $form = &$event->getForm();
...@@ -65,7 +62,7 @@ class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface { ...@@ -65,7 +62,7 @@ class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface {
'#title' => 'Section ID', '#title' => 'Section ID',
'#weight' => 99, '#weight' => 99,
'#default_value' => $config['layout_builder_id'] ?: NULL, '#default_value' => $config['layout_builder_id'] ?: NULL,
'#description' => $this->t('Section ID is an optional setting which is used to support an anchor link to this block. For example, entering "feature" lets you link directly to this section by adding "#feature" to the end of the URL.</br>IDs should start with a letter, may only contain letters, numbers, underscores, hyphens, and periods, and should be unique on the page.'), '#description' => t('Section ID is an optional setting which is used to support an anchor link to this block. For example, entering "feature" lets you link directly to this section by adding "#feature" to the end of the URL.</br>IDs should start with a letter, may only contain letters, numbers, underscores, hyphens, and periods, and should be unique on the page.'),
]; ];
// Add the form validation for configure block. // Add the form validation for configure block.
...@@ -82,7 +79,7 @@ class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface { ...@@ -82,7 +79,7 @@ class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function layoutBuilderIdsConfigureSectionFormValidation(array &$form, FormStateInterface $form_state) { public static function layoutBuilderIdsConfigureSectionFormValidation(array &$form, FormStateInterface $form_state) {
// Get the layout builder id from the form. // Get the layout builder id from the form.
$layout_builder_id = $form_state->getValue( $layout_builder_id = $form_state->getValue(
...@@ -114,7 +111,7 @@ class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface { ...@@ -114,7 +111,7 @@ class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function layoutBuilderIdsConfigureSectionSubmitForm(array &$form, FormStateInterface $form_state) { public static function layoutBuilderIdsConfigureSectionSubmitForm(array &$form, FormStateInterface $form_state) {
// Get the layout builder id from the form. // Get the layout builder id from the form.
$layout_builder_id = $form_state->getValue( $layout_builder_id = $form_state->getValue(
......
...@@ -32,7 +32,7 @@ class LayoutBuilderIdsRenderSubscriber implements EventSubscriberInterface { ...@@ -32,7 +32,7 @@ class LayoutBuilderIdsRenderSubscriber implements EventSubscriberInterface {
* @param \Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent $event * @param \Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent $event
* The section component render event. * The section component render event.
*/ */
public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) { public static function onBuildRender(SectionComponentBuildRenderArrayEvent $event) {
// The render array. // The render array.
$build = $event->getBuild(); $build = $event->getBuild();
......
...@@ -16,7 +16,7 @@ class LayoutBuilderIdsService implements LayoutBuilderIdsServiceInterface { ...@@ -16,7 +16,7 @@ class LayoutBuilderIdsService implements LayoutBuilderIdsServiceInterface {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function layoutBuilderIdsCheckIds(string $layout_builder_id, FormStateInterface $form_state, string $type):bool { public static function layoutBuilderIdsCheckIds(string $layout_builder_id, FormStateInterface $form_state, string $type):bool {
// Return the found id, which will tell us if we have a // Return the found id, which will tell us if we have a
// duplicate id. // duplicate id.
...@@ -27,7 +27,7 @@ class LayoutBuilderIdsService implements LayoutBuilderIdsServiceInterface { ...@@ -27,7 +27,7 @@ class LayoutBuilderIdsService implements LayoutBuilderIdsServiceInterface {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function layoutBuilderIdsCheckSectionIds(string $layout_builder_id, FormStateInterface $form_state, string $type):bool { public static function layoutBuilderIdsCheckSectionIds(string $layout_builder_id, FormStateInterface $form_state, string $type):bool {
// Get the sections from the formObject. // Get the sections from the formObject.
$sections = $form_state->getFormObject()->getSectionStorage()->getSections(); $sections = $form_state->getFormObject()->getSectionStorage()->getSections();
...@@ -74,7 +74,7 @@ class LayoutBuilderIdsService implements LayoutBuilderIdsServiceInterface { ...@@ -74,7 +74,7 @@ class LayoutBuilderIdsService implements LayoutBuilderIdsServiceInterface {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function layoutBuilderIdsCheckBlockIds(string $layout_builder_id, FormStateInterface $form_state, string $type):bool { public static function layoutBuilderIdsCheckBlockIds(string $layout_builder_id, FormStateInterface $form_state, string $type):bool {
// Get the sections from the formObject. // Get the sections from the formObject.
$sections = $form_state->getFormObject()->getSectionStorage()->getSections(); $sections = $form_state->getFormObject()->getSectionStorage()->getSections();
......
...@@ -24,7 +24,7 @@ interface LayoutBuilderIdsServiceInterface { ...@@ -24,7 +24,7 @@ interface LayoutBuilderIdsServiceInterface {
* @return bool * @return bool
* A boolean value to whether or not there is a duplicate id. * A boolean value to whether or not there is a duplicate id.
*/ */
public function layoutBuilderIdsCheckIds(string $layout_builder_id, FormStateInterface $form_state, string $type):bool; public static function layoutBuilderIdsCheckIds(string $layout_builder_id, FormStateInterface $form_state, string $type):bool;
/** /**
* Function to check the sections for duplicate ids. * Function to check the sections for duplicate ids.
...@@ -39,7 +39,7 @@ interface LayoutBuilderIdsServiceInterface { ...@@ -39,7 +39,7 @@ interface LayoutBuilderIdsServiceInterface {
* @return bool * @return bool
* A boolean value to whether or not there is a duplicate id. * A boolean value to whether or not there is a duplicate id.
*/ */
public function layoutBuilderIdsCheckSectionIds(string $layout_builder_id, FormStateInterface $form_state, string $type):bool; public static function layoutBuilderIdsCheckSectionIds(string $layout_builder_id, FormStateInterface $form_state, string $type):bool;
/** /**
* A function to check the blocks for a duplicate id. * A function to check the blocks for a duplicate id.
...@@ -54,6 +54,6 @@ interface LayoutBuilderIdsServiceInterface { ...@@ -54,6 +54,6 @@ interface LayoutBuilderIdsServiceInterface {
* @return bool * @return bool
* A boolean value to whether or not there is a duplicate id. * A boolean value to whether or not there is a duplicate id.
*/ */
public function layoutBuilderIdsCheckBlockIds(string $layout_builder_id, FormStateInterface $form_state, string $type):bool; public static function layoutBuilderIdsCheckBlockIds(string $layout_builder_id, FormStateInterface $form_state, string $type):bool;
} }
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