migrate_spip-1.0.0/src/Plugin/SpipRichText/Bolds.php

src/Plugin/SpipRichText/Bolds.php
<?php

declare(strict_types=1);

namespace Drupal\migrate_spip\Plugin\SpipRichText;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\migrate_spip\Attribute\SpipRichText;
use Drupal\migrate_spip\SpipRichTextBase;

/**
 * Manage SPIP bolds.
 *
 * Need to be executed after subheadings.
 */
#[SpipRichText(
  id: 'bolds',
  label: new TranslatableMarkup('Bold'),
  weight: -19,
)]
final class Bolds extends SpipRichTextBase {

  /**
   * {@inheritdoc}
   */
  public function apply(string $text): string {
    return str_replace(
      [
        // Empty bold.
        '{{}}',
        '{{',
        '}}',
      ],
      [
        '',
        '<strong>',
        '</strong>',
      ],
      $text
    );
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc