first commit

This commit is contained in:
2024-07-15 12:33:27 +02:00
commit ce50ae282b
22084 changed files with 2623791 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
namespace Drupal\{{ machine_name }}\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Configure {{ name }} settings for this site.
*/
final class {{ class }} extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId(): string {
return '{{ form_id }}';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames(): array {
return ['{{ machine_name }}.settings'];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state): array {
$form['example'] = [
'#type' => 'textfield',
'#title' => $this->t('Example'),
'#default_value' => $this->config('{{ machine_name }}.settings')->get('example'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state): void {
// @todo Validate the form here.
// Example:
// @code
// if ($form_state->getValue('example') === 'wrong') {
// $form_state->setErrorByName(
// 'message',
// $this->t('The value is not correct.'),
// );
// }
// @endcode
parent::validateForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state): void {
$this->config('{{ machine_name }}.settings')
->set('example', $form_state->getValue('example'))
->save();
parent::submitForm($form, $form_state);
}
}

View File

@@ -0,0 +1,10 @@
{{ route_name }}:
title: {{ link_title }}
{% if link_description %}
description: {{ link_description }}
{% endif %}
{% if link_parent %}
parent: {{ link_parent }}
{% endif %}
route_name: {{ route_name }}
weight: 10

View File

@@ -0,0 +1,7 @@
{{ route_name }}:
path: '{{ route_path }}'
defaults:
_title: '{{ route_title }}'
_form: 'Drupal\{{ machine_name }}\Form\{{ class }}'
requirements:
_permission: '{{ route_permission }}'

View File

@@ -0,0 +1,8 @@
# Schema for the configuration files of the {{ name }} module.
{{ machine_name }}.settings:
type: config_object
label: '{{ name }} settings'
mapping:
example:
type: string
label: 'Example'

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace Drupal\{{ machine_name }}\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
/**
* @todo Add a description for the form.
*/
final class {{ class }} extends ConfirmFormBase {
/**
* {@inheritdoc}
*/
public function getFormId(): string {
return '{{ form_id }}';
}
/**
* {@inheritdoc}
*/
public function getQuestion(): TranslatableMarkup {
return $this->t('Are you sure you want to do this?');
}
/**
* {@inheritdoc}
*/
public function getCancelUrl(): Url {
return new Url('system.admin_config');
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state): void {
// @todo Place your code here.
$this->messenger()->addStatus($this->t('Done!'));
$form_state->setRedirectUrl(new Url('system.admin_config'));
}
}

View File

@@ -0,0 +1,7 @@
{{ route_name }}:
path: '{{ route_path }}'
defaults:
_title: '{{ route_title }}'
_form: 'Drupal\{{ machine_name }}\Form\{{ class }}'
requirements:
_permission: '{{ route_permission }}'

View File

@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
namespace Drupal\{{ machine_name }}\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides a {{ name }} form.
*/
final class {{ class }} extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId(): string {
return '{{ form_id }}';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state): array {
$form['message'] = [
'#type' => 'textarea',
'#title' => $this->t('Message'),
'#required' => TRUE,
];
$form['actions'] = [
'#type' => 'actions',
'submit' => [
'#type' => 'submit',
'#value' => $this->t('Send'),
],
];
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state): void {
// @todo Validate the form here.
// Example:
// @code
// if (mb_strlen($form_state->getValue('message')) < 10) {
// $form_state->setErrorByName(
// 'message',
// $this->t('Message should be at least 10 characters.'),
// );
// }
// @endcode
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state): void {
$this->messenger()->addStatus($this->t('The message has been sent.'));
$form_state->setRedirect('<front>');
}
}

View File

@@ -0,0 +1,7 @@
{{ route_name }}:
path: '{{ route_path }}'
defaults:
_title: '{{ route_title }}'
_form: 'Drupal\{{ machine_name }}\Form\{{ class }}'
requirements:
_permission: '{{ route_permission }}'