Commit bdb37bb7 authored by Elber Rodrigues's avatar Elber Rodrigues Committed by Damien McKenna
Browse files

Issue #3271009 by DamienMcKenna, elber, Guilherme Rabelo, marciaibanez: Fix coding standards.

parent 98e901eb
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ Search and Replace Scanner 8.x-1.x-dev, 2022-xx-xx
#3302647 by p-neyens, DamienMcKenna: Fieldsets in settings form aren't
  collapsible.
#3313080 by DamienMcKenna: Drupal 10 compatibility.
#3271009 by DamienMcKenna, elber, Guilherme Rabelo, marciaibanez: Fix coding
  standards.


Search and Replace Scanner 8.x-1.0-rc6, 2021-11-19
+5 −0
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Primary hook implementations for the Scanner module.
 */

/**
 * Implements hook_theme().
 */
+3 −3
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@ class AdminHelper {
  /**
   * Log or show a notice message on the screen.
   */
  public static function addToLog($message, $DEBUG = FALSE) {
    if ($DEBUG) {
  public static function addToLog($message, $debug = FALSE) {
    if ($debug) {
      \Drupal::logger('scanner')->notice($message);
    }
  }
@@ -76,7 +76,7 @@ class AdminHelper {
  /**
   * Get the latest revision.
   */
  public static function _latest_revision($nid, &$vid, $langcode) {
  public static function latestRevision($nid, &$vid, $langcode) {
    // Change record below might be helpful for future improvements.
    // @see https://www.drupal.org/node/2942013
    $lang = \Drupal::languageManager()->getCurrentLanguage()->getId();
+41 −5
Original line number Diff line number Diff line
@@ -5,12 +5,49 @@ namespace Drupal\scanner\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url;
use Drupal\Core\Link;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Database\Connection;

/**
 * Controller for Search and Replace module.
 */
class ScannerController extends ControllerBase {

  /**
   * Drupal\Core\Datetime\DateFormatter.
   *
   * @var \Drupal\Core\Datetime\DateFormatter
   */
  protected $dateFormatter;

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

  /**
   * Class constructor.
   */
  public function __construct(DateFormatter $dateFormatter, Connection $database) {
    $this->dateFormatter = $dateFormatter;
    $this->database = $database;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    // Instantiates this form class.
    return new static(
      // Load the service required to construct this class.
      $container->get('date.formatter'),
      $container->get('database'),
    );
  }

  /**
   * Queries the database and builds the results for the "Undo" listing.
   *
@@ -18,8 +55,7 @@ class ScannerController extends ControllerBase {
   *   A render array (table).
   */
  public function undoListing() {
    $connection = \Drupal::service('database');
    $query = $connection->query('SELECT * from {scanner} WHERE undone = 0');
    $query = $this->database->query('SELECT * from {scanner} WHERE undone = 0');
    $results = $query->fetchAll();
    $header = [
      $this->t('Date'),
@@ -34,7 +70,7 @@ class ScannerController extends ControllerBase {
    foreach ($results as $result) {
      $undo_link = Link::fromTextAndUrl($this->t('Undo'), Url::fromUri("internal:/admin/content/scanner/undo/$result->undo_id/confirm"))->toString();
      $rows[] = [
        \Drupal::service('date.formatter')->format($result->time),
        $this->date_formatter->format($result->time),
        $result->searched,
        $result->replaced,
        $result->count,
+2 −2
Original line number Diff line number Diff line
@@ -277,12 +277,12 @@ class ScannerAdminForm extends ConfigFormBase {
        // or the entity type no longer exists.
        continue;
      }
      list($entity_type, $bundle) = explode(':', $key);
      [$entity_type, $bundle] = explode(':', $key);
      // Get the fields for the given entity type and bundle.
      $field_definitions = $this->entityFieldManager->getFieldDefinitions($entity_type, $bundle);
      foreach ($field_definitions as $field_name => $field_definition) {
        $allowed_field_type = [
          // TODO:codebymikey:20200210 why no string_long?
          // @todo Why no string_long?
          'string', 'text_with_summary', 'text', 'text_long',
        ];
        // We are only interested in certain field types.
Loading