Verified Commit 40b5046f authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3443486 by smustgrave: Remove deprecated code from lib/Batch and lib/Datetime

parent eb219dc4
Loading
Loading
Loading
Loading
Loading
+7 −36
Original line number Diff line number Diff line
@@ -15,32 +15,6 @@ class BatchStorage implements BatchStorageInterface {
   */
  const TABLE_NAME = 'batch';

  /**
   * The database connection.
   *
   * @var \Drupal\Core\Database\Connection
   */
  protected $connection;

  /**
   * The session.
   *
   * @var \Symfony\Component\HttpFoundation\Session\SessionInterface
   */
  protected $session;

  /**
   * The CSRF token generator.
   *
   * @var \Drupal\Core\Access\CsrfTokenGenerator
   */
  protected $csrfToken;

  /**
   * The time service.
   */
  protected readonly TimeInterface $time;

  /**
   * Constructs the database batch storage service.
   *
@@ -48,20 +22,17 @@ class BatchStorage implements BatchStorageInterface {
   *   The database connection.
   * @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session
   *   The session.
   * @param \Drupal\Core\Access\CsrfTokenGenerator $csrf_token
   * @param \Drupal\Core\Access\CsrfTokenGenerator $csrfToken
   *   The CSRF token generator.
   * @param \Drupal\Component\Datetime\TimeInterface $time
   *   The time service.
   */
  public function __construct(Connection $connection, SessionInterface $session, CsrfTokenGenerator $csrf_token, TimeInterface $time = NULL) {
    $this->connection = $connection;
    $this->session = $session;
    $this->csrfToken = $csrf_token;
    if (!$time) {
      @trigger_error('Calling ' . __METHOD__ . '() without the $time argument is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/3220378', E_USER_DEPRECATED);
      $time = \Drupal::service('datetime.time');
    }
    $this->time = $time;
  public function __construct(
    protected Connection $connection,
    protected SessionInterface $session,
    protected CsrfTokenGenerator $csrfToken,
    protected TimeInterface $time,
  ) {
  }

  /**
+0 −23
Original line number Diff line number Diff line
@@ -375,29 +375,6 @@ public static function validateDatetime(&$element, FormStateInterface $form_stat
    }
  }

  /**
   * Creates an example for a date format.
   *
   * This is centralized for a consistent method of creating these examples.
   *
   * @param string $format
   *   The date format.
   *
   * @return string
   *
   * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0.
   *   There is no replacement.
   *
   * @see https://www.drupal.org/node/3385058
   */
  public static function formatExample($format) {
    @trigger_error(__METHOD__ . ' is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3385058', E_USER_DEPRECATED);
    if (!static::$dateExample) {
      static::$dateExample = new DrupalDateTime();
    }
    return static::$dateExample->format($format);
  }

  /**
   * Retrieves the right format for an HTML5 date element.
   *