Skip to content
Snippets Groups Projects

Resolve #3421012 "Convert filter plugin"

Closed quietone requested to merge issue/drupal-3421012:3421012-convert-filter-plugin into 11.x

Closes #3421012

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
36 * behavior.
37 * @param int|null $type
38 * The filter type. Values are defined in
39 * \Drupal\filter\Plugin\FilterInterface.
40 * @param int|null $weight
41 * (optional) A default weight for the filter in new text formats.
42 * @param bool|null $status
43 * (optional) Whether this filter is enabled or disabled by default.
44 * @param array|null $settings
45 * (optional) The default settings for the filter.
46 */
47 public function __construct(
48 public readonly string $id,
49 public readonly ?TranslatableMarkup $title = NULL,
50 public readonly ?TranslatableMarkup $description = NULL,
51 public readonly ?int $type = FilterInterface::TYPE_MARKUP_LANGUAGE,
  • Michael Strelan
  • Michael Strelan
  • Michael Strelan
  • quietone added 1 commit

    added 1 commit

    Compare with previous version

  • 1 <?php
    2
    3 namespace Drupal\filter\Attribute;
    4
    5 use Drupal\Component\Plugin\Attribute\Plugin;
    6 use Drupal\Core\StringTranslation\TranslatableMarkup;
    7 use Drupal\filter\Plugin\FilterInterface;
    8
    9 /**
    10 * Defines a filter attribute for plugin discovery.
    11 *
    12 * Plugin Namespace: Plugin\Filter
    13 *
    14 * For a working example, see \Drupal\filter\Plugin\Filter\FilterHtml
  • 10 * Defines a filter attribute for plugin discovery.
    11 *
    12 * Plugin Namespace: Plugin\Filter
    13 *
    14 * For a working example, see \Drupal\filter\Plugin\Filter\FilterHtml
    15 *
    16 * @see \Drupal\filter\FilterPluginManager
    17 * @see \Drupal\filter\Plugin\FilterInterface
    18 * @see \Drupal\filter\Plugin\FilterBase
    19 * @see plugin_api
    20 */
    21 #[\Attribute(\Attribute::TARGET_CLASS)]
    22 class Filter extends Plugin {
    23
    24 /**
    25 * Constructs an Filter attribute.
  • 28 * The plugin ID.
    29 * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $title
    30 * The human-readable name of the filter. This is used as an administrative
    31 * summary of what the filter does.
    32 * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
    33 * (optional) Additional administrative information about the filter's
    34 * behavior.
    35 * @param int|null $type
    36 * The filter type. Values are defined in
    37 * \Drupal\filter\Plugin\FilterInterface.
    38 * @param int|null $weight
    39 * (optional) A default weight for the filter in new text formats.
    40 * @param bool|null $status
    41 * (optional) Whether this filter is enabled or disabled by default.
    42 * @param array|null $settings
    43 * (optional) The default settings for the filter.
  • added 1 commit

    Compare with previous version

  • 31 * type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_REVERSIBLE,
    32 * settings = {
    33 * "default_view_mode" = "default",
    34 * "allowed_view_modes" = {},
    35 * "allowed_media_types" = {},
    36 * },
    37 * weight = 100,
    38 * )
    39 *
    40 30 * @internal
    41 31 */
    32 #[Filter(
    33 id: "media_embed",
    34 title: new TranslatableMarkup("Embed media"),
    35 description: new TranslatableMarkup("Embeds media items using a custom tag, <code>&lt;drupal-media&gt;</code>. If used in conjunction with the 'Align/Caption' filters, make sure this filter is configured to run after them."),
    36 type: FilterInterface::TYPE_TRANSFORM_REVERSIBLE,
  • sorlov added 238 commits

    added 238 commits

    Compare with previous version

  • sorlov added 1 commit

    added 1 commit

    Compare with previous version

  • sorlov added 1 commit

    added 1 commit

    Compare with previous version

  • sorlov added 1 commit

    added 1 commit

    Compare with previous version

  • 1 <?php
    2
    3 namespace Drupal\filter\Attribute;
    • Comment on lines +1 to +3
      Suggested change
      Applied
      3 <?php
      4
      5 namespace Drupal\filter\Attribute;
      3 <?php
      4
      5 declare(strict_types=1);
      6
      7 namespace Drupal\filter\Attribute;
    • Please register or sign in to reply
  • 22 class Filter extends Plugin {
    23
    24 /**
    25 * Constructs a Filter attribute.
    26 *
    27 * @param string $id
    28 * The plugin ID.
    29 * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $title
    30 * The human-readable name of the filter. This is used as an administrative
    31 * summary of what the filter does.
    32 * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
    33 * (optional) Additional administrative information about the filter's
    34 * behavior.
    35 * @param int $type
    36 * (optional) The filter type. Values are defined in
    37 * \Drupal\filter\Plugin\FilterInterface.
  • 16 * @see \Drupal\filter\FilterPluginManager
    17 * @see \Drupal\filter\Plugin\FilterInterface
    18 * @see \Drupal\filter\Plugin\FilterBase
    19 * @see plugin_api
    20 */
    21 #[\Attribute(\Attribute::TARGET_CLASS)]
    22 class Filter extends Plugin {
    23
    24 /**
    25 * Constructs a Filter attribute.
    26 *
    27 * @param string $id
    28 * The plugin ID.
    29 * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $title
    30 * The human-readable name of the filter. This is used as an administrative
    31 * summary of what the filter does.
    • Comment on lines +29 to +31

      :bug: The docs at \Drupal\filter\Plugin\FilterInterface say this is required, and the docs here say it too, but the typehint does not:

      Suggested change
      Applied
      30 * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $title
      31 * The human-readable name of the filter. This is used as an administrative
      32 * summary of what the filter does.
      30 * @param \Drupal\Core\StringTranslation\TranslatableMarkup $title
      31 * The human-readable name of the filter. This is used as an administrative
      32 * summary of what the filter does.
    • Please register or sign in to reply
  • 32 * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
    33 * (optional) Additional administrative information about the filter's
    34 * behavior.
    35 * @param int $type
    36 * (optional) The filter type. Values are defined in
    37 * \Drupal\filter\Plugin\FilterInterface.
    38 * @param int $weight
    39 * (optional) A default weight for the filter in new text formats.
    40 * @param bool $status
    41 * (optional) Whether this filter is enabled or disabled by default.
    42 * @param array $settings
    43 * (optional) The default settings for the filter.
    44 */
    45 public function __construct(
    46 public readonly string $id,
    47 public readonly ?TranslatableMarkup $title = NULL,
  • 34 * behavior.
    35 * @param int $type
    36 * (optional) The filter type. Values are defined in
    37 * \Drupal\filter\Plugin\FilterInterface.
    38 * @param int $weight
    39 * (optional) A default weight for the filter in new text formats.
    40 * @param bool $status
    41 * (optional) Whether this filter is enabled or disabled by default.
    42 * @param array $settings
    43 * (optional) The default settings for the filter.
    44 */
    45 public function __construct(
    46 public readonly string $id,
    47 public readonly ?TranslatableMarkup $title = NULL,
    48 public readonly ?TranslatableMarkup $description = NULL,
    49 public readonly int $type = FilterInterface::TYPE_MARKUP_LANGUAGE,
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading