reviewer-1.2.x-dev/modules/reviewer_test_kit/src/Plugin/reviewer/Task/Entity/Display/View/ViewFieldsDisabledTaskBase.php
modules/reviewer_test_kit/src/Plugin/reviewer/Task/Entity/Display/View/ViewFieldsDisabledTaskBase.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\FieldsDisabledTaskBase;
/**
* Base task for checking if fields are disabled on entity view display forms.
*
* Tasks extending this class only need to define one or both of the $fieldTypes
* or $fieldNames properties; the task takes care of checking and fixing
* non-hidden fields automatically.
*
* If either the $fieldTypes or $fieldNames properties are empty, a
* \LogicException will be thrown.
*
* Example of a fixable task which checks that certain fields types are always
* disabled on search index view modes:
*
* @code
* #[Task(
* id: 'search_fields_disabled',
* module_dependencies: ['search_api'],
* )]
* final class SearchFieldsDisabled extends ViewFieldsDisabledTaskBase {
*
* protected array $fieldTypes = [
* 'email_mailto',
* 'default:media' => 'entity_reference',
* 'link',
* 'telephone_link',
* ];
*
* protected function displays(): array {
* return array_filter(
* parent::displays(),
* fn(string $mode): bool => $mode === 'search_index',
* ARRAY_FILTER_USE_KEY,
* );
* }
*
* }
* @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
*/
abstract class ViewFieldsDisabledTaskBase extends FieldsDisabledTaskBase {
/**
* {@inheritdoc}
*/
protected string $displayType = 'view';
}
