Commit 83cabdda authored by matsbla's avatar matsbla Committed by Mats Blakstad
Browse files

Issue #3315537 by matsbla: Fix coding standards (pareview.sh)

parent 1882790b
Loading
Loading
Loading
Loading
+23 −23
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@ use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Twig_Error;

/**
 * Plugin implementation of the 'custom_twig_markup' formatter.
@@ -118,7 +117,7 @@ class CustomTwigFormatter extends FormatterBase {
      '#default_value' => $this->getSetting('custom_twig_markup'),
    ];

    // Generate help text for replacement patterns
    // Generate help text for replacement patterns.
    $configTarget = $this->fieldDefinition->getConfigTarget();
    $configTarget = explode('.', $configTarget);
    $entity_type = $configTarget[0];
@@ -138,10 +137,10 @@ class CustomTwigFormatter extends FormatterBase {
    $tokensDoc = [
      'label'             => 'string',
      'css_classes'       => 'string',
      'title_css_classes' => 'string'
      'title_css_classes' => 'string',
    ];

    // Build documentation
    // Build documentation.
    $field_name            = $this->fieldDefinition->getName();
    $tokens_current_field  = '<dl>';
    $tokens_all            = '<dl>';
@@ -187,7 +186,7 @@ class CustomTwigFormatter extends FormatterBase {
    $field_name = $this->fieldDefinition->getName();
    $field_type = $this->fieldDefinition->getType();
    $label_display_position = $this->label;
    // field_display_label module integration
    // field_display_label module integration.
    $field_display_label_module = $this->moduleHandler->moduleExists('field_display_label');
    if ($field_display_label_module) {
      $field_definition = $entity->getFieldDefinition($field_name);
@@ -202,7 +201,7 @@ class CustomTwigFormatter extends FormatterBase {
    else {
      $label = $this->fieldDefinition->getLabel();
    }
    // Build default field classes
    // Build default field classes.
    $field_name_class = str_replace('_', '-', $field_name);
    $field_type_class = str_replace('_', '-', $field_type);
    $label_display_class = str_replace('_', '-', $label_display_position);
@@ -218,7 +217,7 @@ class CustomTwigFormatter extends FormatterBase {
      $title_css_classes .= ' visually-hidden';
    }

    // Load twig field replacement patterns
    // Load twig field replacement patterns.
    $context = [];
    foreach ($entity->getFields() as $field_id => $value) {
      $context[$field_id] = $value;
@@ -227,12 +226,13 @@ class CustomTwigFormatter extends FormatterBase {
    $context['css_classes'] = $css_classes;
    $context['title_css_classes'] = $title_css_classes;

    // Build twig markup
    // Build twig markup.
    $output = '';
    try {
      $output = $this->twig->createTemplate($this->getSetting('custom_twig_markup'))
        ->render($context);
    } catch (Twig_Error $error) {
    }
    catch (Twig_Error $error) {
      $this->messenger()->addError($error->getMessage());
    }
    if ($this->getSetting('use_default_field_markup_wrapper')) {
@@ -261,9 +261,9 @@ class CustomTwigFormatter extends FormatterBase {
      '#items' => $items,
      '#formatter' => $this->getPluginId(),
      '#is_multiple' => $this->fieldDefinition->getFieldStorageDefinition()->isMultiple(),
      '#third_party_settings' => $this->getThirdPartySettings()
      '#third_party_settings' => $this->getThirdPartySettings(),
    ];
    // @todo: Attach libraries for all fields in a generic way
    // @todo: Fix attaching libraries for all fields in a generic way here.
    if ($field_type == 'file') {
      $elements['#attached']['library'][] = "file/drupal.file";
    }