Verified Commit 5509149c authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3497408 by quietone: Fix DrupalPractice.Objects.GlobalFunction in modules

parent 3ac83171
Loading
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
use Drupal\Component\Utility\Html;
use Drupal\Core\Render\ElementInfoManagerInterface;
use Drupal\Core\Security\TrustedCallbackInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Url;

/**
@@ -17,6 +18,8 @@
 */
final class LazyBuilders implements TrustedCallbackInterface {

  use StringTranslationTrait;

  /**
   * Constructs LazyBuilders object.
   *
@@ -40,11 +43,11 @@ public function renderAnnouncements(): array {
      '#cache' => [
        'context' => ['user.permissions'],
      ],
      '#title' => t('Announcements'),
      '#title' => $this->t('Announcements'),
      '#url' => Url::fromRoute('announcements_feed.announcement'),
      '#id' => Html::getId('toolbar-item-announcement'),
      '#attributes' => [
        'title' => t('Announcements'),
        'title' => $this->t('Announcements'),
        'data-drupal-announce-trigger' => '',
        'class' => [
          'toolbar-icon',
+1 −1
Original line number Diff line number Diff line
@@ -392,7 +392,7 @@ public function save(array $form, FormStateInterface $form_state) {
      // Add a log entry.
      $logger->info('Comment posted: %subject.', [
        '%subject' => $comment->getSubject(),
        'link' => Link::fromTextAndUrl(t('View'), $comment->toUrl()->setOption('fragment', 'comment-' . $comment->id()))->toString(),
        'link' => Link::fromTextAndUrl($this->t('View'), $comment->toUrl()->setOption('fragment', 'comment-' . $comment->id()))->toString(),
      ]);
      // Add an appropriate message upon submitting the comment form.
      $this->messenger()->addStatus($this->getStatusMessage($comment, $is_new));
+8 −5
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
use Drupal\Core\Security\TrustedCallbackInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Url;

/**
@@ -18,6 +19,8 @@
 */
class CommentLazyBuilders implements TrustedCallbackInterface {

  use StringTranslationTrait;

  /**
   * The entity type manager service.
   *
@@ -172,14 +175,14 @@ protected function buildLinks(CommentInterface $entity, EntityInterface $comment
    if ($status == CommentItemInterface::OPEN) {
      if ($entity->access('delete')) {
        $links['comment-delete'] = [
          'title' => t('Delete'),
          'title' => $this->t('Delete'),
          'url' => $entity->toUrl('delete-form'),
        ];
      }

      if ($entity->access('update')) {
        $links['comment-edit'] = [
          'title' => t('Edit'),
          'title' => $this->t('Edit'),
          'url' => $entity->toUrl('edit-form'),
        ];
      }
@@ -188,7 +191,7 @@ protected function buildLinks(CommentInterface $entity, EntityInterface $comment
        && $entity->access('create')
        && $field_definition->getSetting('default_mode') === CommentManagerInterface::COMMENT_MODE_THREADED) {
        $links['comment-reply'] = [
          'title' => t('Reply'),
          'title' => $this->t('Reply'),
          'url' => Url::fromRoute('comment.reply', [
            'entity_type' => $entity->getCommentedEntityTypeId(),
            'entity' => $entity->getCommentedEntityId(),
@@ -199,7 +202,7 @@ protected function buildLinks(CommentInterface $entity, EntityInterface $comment
      }
      if (!$entity->isPublished() && $entity->access('approve')) {
        $links['comment-approve'] = [
          'title' => t('Approve'),
          'title' => $this->t('Approve'),
          'url' => Url::fromRoute('comment.approve', ['comment' => $entity->id()]),
        ];
      }
@@ -211,7 +214,7 @@ protected function buildLinks(CommentInterface $entity, EntityInterface $comment
    // Add translations link for translation-enabled comment bundles.
    if ($this->moduleHandler->moduleExists('content_translation') && $this->access($entity)->isAllowed()) {
      $links['comment-translations'] = [
        'title' => t('Translate'),
        'title' => $this->t('Translate'),
        'url' => $entity->toUrl('drupal:content-translation-overview'),
      ];
    }
+4 −1
Original line number Diff line number Diff line
@@ -10,10 +10,13 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\user\EntityOwnerInterface;

class CommentStatistics implements CommentStatisticsInterface {

  use StringTranslationTrait;

  /**
   * The current database connection.
   *
@@ -173,7 +176,7 @@ public function getMaximumCount($entity_type) {
  public function getRankingInfo() {
    return [
      'comments' => [
        'title' => t('Number of comments'),
        'title' => $this->t('Number of comments'),
        'join' => [
          'type' => 'LEFT',
          'table' => 'comment_entity_statistics',
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En
   * {@inheritdoc}
   */
  protected function entityFormTitle(EntityInterface $entity) {
    return t('Edit comment @subject', ['@subject' => $entity->label()]);
    return $this->t('Edit comment @subject', ['@subject' => $entity->label()]);
  }

  /**
Loading