quickedit_test.module

Same filename in other branches
  1. 8.9.x core/modules/quickedit/tests/modules/quickedit_test.module

Helper module for the Quick Edit tests.

File

core/modules/quickedit/tests/modules/quickedit_test.module

View source
<?php


/**
 * @file
 * Helper module for the Quick Edit tests.
 */
use Drupal\Core\Entity\EntityInterface;

/**
 * Implements hook_quickedit_render_field().
 */
function quickedit_test_quickedit_render_field(EntityInterface $entity, $field_name, $view_mode_id, $langcode) {
    $entity = \Drupal::service('entity.repository')->getTranslationFromContext($entity, $langcode);
    return [
        '#prefix' => '<div class="quickedit-test-wrapper">',
        'field' => $entity->get($field_name)
            ->view($view_mode_id),
        '#suffix' => '</div>',
    ];
}

/**
 * Implements hook_field_formatter_info_alter().
 *
 * @see quickedit_field_formatter_info_alter()
 * @see editor_field_formatter_info_alter()
 */
function quickedit_test_field_formatter_info_alter(&$info) {
    // Update \Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter's
    // annotation to indicate that it supports the 'wysiwyg' in-place editor
    // provided by this module.
    $info['text_default']['quickedit'] = [
        'editor' => 'wysiwyg',
    ];
}

Functions

Title Deprecated Summary
quickedit_test_field_formatter_info_alter Implements hook_field_formatter_info_alter().
quickedit_test_quickedit_render_field Implements hook_quickedit_render_field().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.