SimplesitemapFormBase.php 2.51 KB
Newer Older
gbyte.co's avatar
gbyte.co committed
1 2 3 4
<?php

namespace Drupal\simple_sitemap\Form;

5
use Drupal\simple_sitemap\EntityHelper;
6
use Symfony\Component\DependencyInjection\ContainerInterface;
gbyte.co's avatar
gbyte.co committed
7
use Drupal\Core\Form\ConfigFormBase;
gbyte.co's avatar
gbyte.co committed
8 9
use Drupal\simple_sitemap\Simplesitemap;
use Drupal\Core\Path\PathValidator;
10
use Drupal\Core\Language\LanguageManagerInterface;
gbyte.co's avatar
gbyte.co committed
11 12

/**
gbyte.co's avatar
gbyte.co committed
13
 * Class SimplesitemapFormBase
gbyte.co's avatar
gbyte.co committed
14
 * @package Drupal\simple_sitemap\Form
gbyte.co's avatar
gbyte.co committed
15 16 17
 */
abstract class SimplesitemapFormBase extends ConfigFormBase {

gbyte.co's avatar
gbyte.co committed
18 19 20
  /**
   * @var \Drupal\simple_sitemap\Simplesitemap
   */
21
  protected $generator;
gbyte.co's avatar
gbyte.co committed
22 23 24 25

  /**
   * @var \Drupal\simple_sitemap\Form\FormHelper
   */
26
  protected $formHelper;
gbyte.co's avatar
gbyte.co committed
27 28 29 30

  /**
   * @var \Drupal\simple_sitemap\EntityHelper
   */
31
  protected $entityHelper;
gbyte.co's avatar
gbyte.co committed
32 33 34 35

  /**
   * @var \Drupal\Core\Path\PathValidator
   */
36 37
  protected $pathValidator;

38 39 40 41 42
  /**
   * @var \Drupal\Core\Language\LanguageManagerInterface
   */
  protected $languageManager;

gbyte.co's avatar
gbyte.co committed
43 44
  /**
   * SimplesitemapFormBase constructor.
gbyte.co's avatar
gbyte.co committed
45 46
   * @param \Drupal\simple_sitemap\Simplesitemap $generator
   * @param \Drupal\simple_sitemap\Form\FormHelper $form_helper
47
   * @param \Drupal\simple_sitemap\EntityHelper $entity_helper
gbyte.co's avatar
gbyte.co committed
48
   * @param \Drupal\Core\Path\PathValidator $path_validator
49
   * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
gbyte.co's avatar
gbyte.co committed
50
   */
gbyte.co's avatar
gbyte.co committed
51 52 53
  public function __construct(
    Simplesitemap $generator,
    FormHelper $form_helper,
54
    EntityHelper $entity_helper,
55 56
    PathValidator $path_validator,
    LanguageManagerInterface $language_manager
gbyte.co's avatar
gbyte.co committed
57
  ) {
58
    $this->generator = $generator;
59
    $this->formHelper = $form_helper;
60
    $this->entityHelper = $entity_helper;
61
    $this->pathValidator = $path_validator;
62
    $this->languageManager = $language_manager;
63 64 65 66 67 68 69 70
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('simple_sitemap.generator'),
71
      $container->get('simple_sitemap.form_helper'),
72
      $container->get('simple_sitemap.entity_helper'),
73 74
      $container->get('path.validator'),
      $container->get('language_manager')
75 76 77
    );
  }

gbyte.co's avatar
gbyte.co committed
78 79 80 81 82 83 84
  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return ['simple_sitemap.settings'];
  }

gbyte.co's avatar
gbyte.co committed
85 86 87
  /**
   *
   */
88
  protected function getDonationText() {
gbyte.co's avatar
gbyte.co committed
89
    return '<div class="description">' . $this->t('If you would like to say thanks and support the development of this module, a <a target="_blank" href="@url">donation</a> will be much appreciated.', ['@url' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5AFYRSBLGSC3W']) . '</div>';
gbyte.co's avatar
gbyte.co committed
90
  }
gbyte.co's avatar
gbyte.co committed
91

gbyte.co's avatar
gbyte.co committed
92
}