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;
use Drupal\Component\Utility\Html;
use Drupal\core_event_dispatcher\Event\Form\FormAlterEvent;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;
use Drupal\layout_builder_ids\Service\LayoutBuilderIdsService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
......@@ -15,8 +14,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
*/
class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface {
use StringTranslationTrait;
/**
* Layout builder ids service.
*
......@@ -40,7 +37,7 @@ class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface {
* @param \Drupal\core_event_dispatcher\Event\Form\FormAlterEvent $event
* The event.
*/
public function alterForm(FormAlterEvent $event): void {
public static function alterForm(FormAlterEvent $event): void {
// Get the form from the event.
$form = &$event->getForm();
......@@ -63,7 +60,7 @@ class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface {
'#title' => 'Block ID',
'#weight' => 99,
'#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.
......@@ -80,7 +77,7 @@ class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface {
/**
* {@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,
// also put the id through the HTML getId to make sure
......@@ -111,7 +108,7 @@ class LayoutBuilderIdsConfigureBlock implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public function layoutBuilderIdsConfigureBlockSubmitForm(array &$form, FormStateInterface $form_state) {
public static function layoutBuilderIdsConfigureBlockSubmitForm(array &$form, FormStateInterface $form_state) {
// Load in the layout_builder_id.
$layout_builder_id = $form_state->getValue(['settings', 'layout_builder_id']);
......
......@@ -5,7 +5,6 @@ namespace Drupal\layout_builder_ids\EventSubscriber;
use Drupal\Component\Utility\Html;
use Drupal\core_event_dispatcher\Event\Form\FormAlterEvent;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;
use Drupal\layout_builder_ids\Service\LayoutBuilderIdsService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
......@@ -15,8 +14,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
*/
class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface {
use StringTranslationTrait;
/**
* Layout builder ids service.
*
......@@ -40,7 +37,7 @@ class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface {
* @param \Drupal\core_event_dispatcher\Event\Form\FormAlterEvent $event
* The event.
*/
public function alterForm(FormAlterEvent $event): void {
public static function alterForm(FormAlterEvent $event): void {
// Get the form from the event.
$form = &$event->getForm();
......@@ -65,7 +62,7 @@ class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface {
'#title' => 'Section ID',
'#weight' => 99,
'#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.
......@@ -82,7 +79,7 @@ class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface {
/**
* {@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.
$layout_builder_id = $form_state->getValue(
......@@ -114,7 +111,7 @@ class LayoutBuilderIdsConfigureSection implements EventSubscriberInterface {
/**
* {@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.
$layout_builder_id = $form_state->getValue(
......
......@@ -32,7 +32,7 @@ class LayoutBuilderIdsRenderSubscriber implements EventSubscriberInterface {
* @param \Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent $event
* The section component render event.
*/
public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) {
public static function onBuildRender(SectionComponentBuildRenderArrayEvent $event) {
// The render array.
$build = $event->getBuild();
......
......@@ -16,7 +16,7 @@ class LayoutBuilderIdsService implements LayoutBuilderIdsServiceInterface {
/**
* {@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
// duplicate id.
......@@ -27,7 +27,7 @@ class LayoutBuilderIdsService implements LayoutBuilderIdsServiceInterface {
/**
* {@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.
$sections = $form_state->getFormObject()->getSectionStorage()->getSections();
......@@ -74,7 +74,7 @@ class LayoutBuilderIdsService implements LayoutBuilderIdsServiceInterface {
/**
* {@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.
$sections = $form_state->getFormObject()->getSectionStorage()->getSections();
......
......@@ -24,7 +24,7 @@ interface LayoutBuilderIdsServiceInterface {
* @return bool
* 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.
......@@ -39,7 +39,7 @@ interface LayoutBuilderIdsServiceInterface {
* @return bool
* 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.
......@@ -54,6 +54,6 @@ interface LayoutBuilderIdsServiceInterface {
* @return bool
* 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