diff --git a/src/Form/TourBuilderCloneForm.php b/src/Form/TourBuilderCloneForm.php
index 4fb22b3..2ff664b 100644
--- a/src/Form/TourBuilderCloneForm.php
+++ b/src/Form/TourBuilderCloneForm.php
@@ -6,12 +6,15 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* Form controller for the tour entity clone form.
*/
class TourBuilderCloneForm extends EntityForm {
+ use StringTranslationTrait;
+
/**
* Entity manager service.
*
@@ -33,10 +36,6 @@ class TourBuilderCloneForm extends EntityForm {
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity manager service.
- * @param \Psr\Log\LoggerInterface $logger
- * A logger instance.
- * @param \Drupal\comment\CommentManagerInterface $comment_manager
- * The comment manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
@@ -55,24 +54,24 @@ class TourBuilderCloneForm extends EntityForm {
'#default_value' => $this->entity->label(),
];
- $form['old_name'] = array(
+ $form['old_name'] = [
'#type' => 'value',
'#value' => $this->entity->getOriginalId(),
- );
+ ];
- $form['new_name'] = array(
+ $form['new_name'] = [
'#title' => 'File name for new tour item.',
'#type' => 'textfield',
- '#description' => 'This value should start with tour.tour. and may not exists.',
+ '#description' => $this->t('This value should start with tour.tour. and may not exists.'),
'#field_prefix' => 'tour.tour.',
'#default_value' => $this->entity->getOriginalId(),
- );
+ ];
- $form['module'] = array(
+ $form['module'] = [
'#title' => 'Module for this tour.',
'#type' => 'textfield',
'#default_value' => $this->entity->getModule(),
- );
+ ];
return $form;
}
@@ -82,7 +81,7 @@ class TourBuilderCloneForm extends EntityForm {
*/
public function validateForm(array &$form, FormStateInterface $form_state, $redirect = TRUE) {
// Make sure new_name does not exists
- // Make sure module exists
+ // Make sure module exists.
$old_name = $form_state->getValue('old_name');
$new_name = $form_state->getValue('new_name');
@@ -99,11 +98,11 @@ class TourBuilderCloneForm extends EntityForm {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state, $redirect = TRUE) {
- // No need to submit the form as we did nothing to the original entity did we?!
- // parent::submitForm($form, $form_state);
-
+ // No need to submit the form as we did nothing to the original
+ // entity did we?!
+ // parent::submitForm($form, $form_state);.
$this->entity = $this->entity->createDuplicate();
- //$this->entity->set('label', $form_state->getValue('label'));
+ // $this->entity->set('label', $form_state->getValue('label'));
$this->entity->set('id', $form_state->getValue('new_name'));
$this->entity->save();
diff --git a/src/Form/TourBuilderExportForm.php b/src/Form/TourBuilderExportForm.php
index 6bb7c86..eff1baa 100644
--- a/src/Form/TourBuilderExportForm.php
+++ b/src/Form/TourBuilderExportForm.php
@@ -4,17 +4,19 @@ namespace Drupal\tour_builder\Form;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\Url;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Serialization\Yaml;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* Form controller for the tour entity clone form.
*/
class TourBuilderExportForm extends EntityForm {
+ use StringTranslationTrait;
+
/**
* Entity manager service.
*
@@ -44,10 +46,8 @@ class TourBuilderExportForm extends EntityForm {
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity manager service.
- * @param \Psr\Log\LoggerInterface $logger
- * A logger instance.
- * @param \Drupal\comment\CommentManagerInterface $comment_manager
- * The comment manager.
+ * @param \Drupal\Core\Config\StorageInterface $config_storage
+ * The config storage service.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, StorageInterface $config_storage) {
$this->entityTypeManager = $entity_type_manager;
@@ -60,8 +60,6 @@ class TourBuilderExportForm extends EntityForm {
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
- $tour = $this->entity;
-
$definition = $this->entityManager->getDefinition('tour');
$name = $definition->getConfigPrefix() . '.' . $this->entity->getOriginalId();
@@ -70,22 +68,11 @@ class TourBuilderExportForm extends EntityForm {
'uuid',
'_core',
];
- foreach($unset_keys as $key) {
+ foreach ($unset_keys as $key) {
unset($config[$key]);
}
$content = Yaml::encode($config);
-// $filename = $name . '.yml';
-// $path = 'temporary://' . $filename;
-// //$link = \Drupal::l($name, Url::fromUri($path));
-// file_put_contents($path, $content);
-
-// $form['link'] = array(
-// '#type' => 'item',
-// '#title' => $this->t('Download'),
-// '#description' => 'Right click to download.',
-// '#markup' => $link,
-// );
$form['export'] = [
'#type' => 'textarea',
'#title' => $this->t('YAML Content'),
@@ -101,8 +88,8 @@ class TourBuilderExportForm extends EntityForm {
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state, $redirect = TRUE) {
- // Make sure new_name does not exists
- // Make sure module exists
+ // Make sure new_name does not exists.
+ // Make sure module exists.
$old_name = $form_state->getValue('old_name');
$new_name = $form_state->getValue('new_name');
@@ -119,9 +106,9 @@ class TourBuilderExportForm extends EntityForm {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state, $redirect = TRUE) {
- // No need to submit the form as we did nothing to the original entity did we?!
- // parent::submitForm($form, $form_state);
-
+ // No need to submit the form as we did nothing to the original
+ // entity did we?!
+ // parent::submitForm($form, $form_state);.
// Redirect to Entity edition.
if ($redirect) {
$form_state->setRedirect('entity.tour.edit_form', ['tour' => $this->entity->id()]);
diff --git a/src/TourBuilderListBuilder.php b/src/TourBuilderListBuilder.php
index 07fb0b9..d482379 100644
--- a/src/TourBuilderListBuilder.php
+++ b/src/TourBuilderListBuilder.php
@@ -4,30 +4,17 @@ namespace Drupal\tour_builder;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
-use Drupal\Core\Config\Entity\ConfigEntityStorageInterface;
-
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
-use Drupal\Component\Utility\Html;
-
use Drupal\tour_ui\TourListBuilder;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* Provides a listing of tours.
*/
class TourBuilderListBuilder extends TourListBuilder {
- /**
- * Constructs a new TourListBuilder object.
- *
- * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
- * The entity type definition.
- * @param \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $storage
- * The config storage class.
- */
- public function __construct(EntityTypeInterface $entity_type, ConfigEntityStorageInterface $storage) {
- parent::__construct($entity_type, $storage);
- }
+ use StringTranslationTrait;
/**
* {@inheritdoc}
@@ -48,13 +35,13 @@ class TourBuilderListBuilder extends TourListBuilder {
$tour = $entity->getOriginalId();
$operations['clone'] = [
- 'title' => t('Clone'),
+ 'title' => $this->t('Clone'),
'url' => $entity->toUrl('clone-form'),
'weight' => 11,
];
$operations['export'] = [
- 'title' => t('Export'),
+ 'title' => $this->t('Export'),
'url' => $entity->toUrl('export-form'),
'weight' => 12,
];
@@ -63,22 +50,15 @@ class TourBuilderListBuilder extends TourListBuilder {
if ($user->hasPermission('export configuration')) {
$operations['export-config'] = [
- 'title' => t('Export (configuration)'),
+ 'title' => $this->t('Export (configuration)'),
'url' => Url::fromRoute('config.export_single', [
'config_type' => 'tour',
- 'config_name' => $tour
+ 'config_name' => $tour,
]),
'weight' => 13,
];
}
- // TODO: fix me
-// $operations['patch'] = [
-// 'title' => t('Patch'),
-// 'url' => $entity->toUrl('edit-form'),
-// 'weight' => 11,
-// ];
-
return $operations;
}
diff --git a/tour_builder.info.yml b/tour_builder.info.yml
index c2db998..3de7a0b 100644
--- a/tour_builder.info.yml
+++ b/tour_builder.info.yml
@@ -2,7 +2,7 @@ name: 'Tour Builder'
type: module
description: 'Helps building and editing tours.'
package: Development
-
core: 8.x
+core_version_requirement: ^8 || ^9
dependencies:
- tour_ui:tour_ui
diff --git a/tour_builder.install b/tour_builder.install
index 8e6a133..bef013e 100644
--- a/tour_builder.install
+++ b/tour_builder.install
@@ -1,8 +1,14 @@
invalidateAll();
}
diff --git a/tour_builder.module b/tour_builder.module
index 8558ee6..b1e35c7 100644
--- a/tour_builder.module
+++ b/tour_builder.module
@@ -5,8 +5,6 @@
* Core functionality for Tour UI module.
*/
-use Drupal\Core\Entity\EntityInterface;
-
/**
* Implements hook_entity_type_alter().
*/