reviewer-1.2.x-dev/modules/reviewer_test_kit/src/Plugin/reviewer/Task/Entity/Display/View/FieldFormattersTaskBase.php

modules/reviewer_test_kit/src/Plugin/reviewer/Task/Entity/Display/View/FieldFormattersTaskBase.php
<?php

declare(strict_types=1);

namespace Drupal\reviewer_test_kit\Plugin\reviewer\Task\Entity\Display\View;

use Drupal\reviewer_test_kit\Plugin\reviewer\Task\Entity\Display\FieldPluginsTaskBase;

/**
 * Base task for checking the field formatters on entity view display forms.
 *
 * Tasks extending this class only need to define the $allowedPlugins and one or
 * both of the $fieldTypes or $fieldNames properties; the task takes care of
 * checking and fixing values automatically. If there is only one allowed
 * plugin, then this task can fix errors. If there is more than one allowed
 * plugin, then the task cannot fix errors because the task cannot determine the
 * correct state.
 *
 * If $allowedPlugins is empty, a \LogicException will be thrown. Tasks
 * extending this class also must define either the $fieldTypes or $fieldNames
 * properties. If both properties are empty, a \LogicException will be thrown.
 *
 * Example of an unfixable task which checks that entity reference fields using
 * the media handler for images use the thumbnail formatters:
 *
 * @code
 * #[Task('media_image_formatter')]
 * final class MediaImageFormatter extends FieldFormattersTaskBase {
 *
 *   protected array $fieldTypes = [
 *     'default:media|image' => 'entity_reference',
 *   ];
 *
 *   protected array $allowed = [
 *     'media_thumbnail',
 *     'media_responsive_thumbnail',
 *   ];
 *
 * }
 * @endcode
 *
 * @see \Drupal\reviewer_test_kit\Plugin\reviewer\Task\Entity\Display\DisplayTaskBase::$displayType
 * @see \Drupal\reviewer_test_kit\Plugin\reviewer\Task\Entity\Display\DisplayFieldsTaskBase::$fieldTypes
 * @see \Drupal\reviewer_test_kit\Plugin\reviewer\Task\Entity\Display\DisplayFieldsTaskBase::$fieldNames
 * @see \Drupal\reviewer_test_kit\Plugin\reviewer\Task\Entity\Display\FieldPluginsTaskBase::$allowedPlugins
 */
abstract class FieldFormattersTaskBase extends FieldPluginsTaskBase {

  /**
   * {@inheritdoc}
   */
  protected string $displayType = 'view';

}

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

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