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

namespace Drupal\simple_sitemap\Form;

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

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

17
  protected $generator;
18
  protected $formHelper;
19 20
  protected $pathValidator;

gbyte.co's avatar
gbyte.co committed
21 22 23
  /**
   * SimplesitemapFormBase constructor.
   *
gbyte.co's avatar
gbyte.co committed
24 25 26
   * @param \Drupal\simple_sitemap\Simplesitemap $generator
   * @param \Drupal\simple_sitemap\Form\FormHelper $form_helper
   * @param \Drupal\Core\Path\PathValidator $path_validator
gbyte.co's avatar
gbyte.co committed
27
   */
gbyte.co's avatar
gbyte.co committed
28 29 30 31 32
  public function __construct(
    Simplesitemap $generator,
    FormHelper $form_helper,
    PathValidator $path_validator
  ) {
33
    $this->generator = $generator;
34
    $this->formHelper = $form_helper;
35 36 37 38 39 40 41 42 43
    $this->pathValidator = $path_validator;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('simple_sitemap.generator'),
44
      $container->get('simple_sitemap.form_helper'),
45 46 47 48
      $container->get('path.validator')
    );
  }

gbyte.co's avatar
gbyte.co committed
49 50 51 52 53 54 55
  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return ['simple_sitemap.settings'];
  }

gbyte.co's avatar
gbyte.co committed
56 57 58
  /**
   *
   */
59
  protected function getDonationText() {
gbyte.co's avatar
gbyte.co committed
60 61
    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> is always appreciated.", ['@url' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5AFYRSBLGSC3W']) . "</div>";
  }
gbyte.co's avatar
gbyte.co committed
62

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