Problem/Motivation

Currently, the text format is not configured for the sources.

Proposed resolution

add the #format attribute for the sources which has filter_format definition

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Status: Needs review » Needs work
+++ b/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php
@@ -105,6 +105,9 @@ class ContentEntitySource extends SourcePluginBase {
+          if($property_definition->getDataType() == 'filter_format'){
+            $data[$key][$index][$property_key]['#format'] = $property->getValue();
+          }

+++ b/sources/content/src/Tests/ContentEntitySourceUnitTest.php
@@ -140,6 +140,7 @@ class ContentEntitySourceUnitTest extends EntityUnitTestBase {
+    $this->assertEqual($data['field_test_text'][0]['format']['#format'], 'text_plain');

@@ -149,6 +150,7 @@ class ContentEntitySourceUnitTest extends EntityUnitTestBase {
+    $this->assertEqual($data['field_test_text'][0]['format']['#format'], 'text_plain');

The format needs to be on value, not on format, we just carry format around to be able to set it again at the end. value is the value that we care about and show a text field for.

Anushka-mp’s picture

Status: Needs work » Needs review
FileSize
2.58 KB
2.38 KB

#format property removed from format to value.

Anushka-mp’s picture

#format added for all the translatable field, tests extended.

Berdir’s picture

Status: Needs review » Needs work
+++ b/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php
@@ -106,7 +106,12 @@ class ContentEntitySource extends SourcePluginBase {
+        foreach ($data[$key][$index] as $name => $value){
+          if (isset($value['#translate']) && $value['#translate'] == TRUE && !empty($format)){
+            $data[$key][$index][$name]['#format'] = $format;
           }
         }

This is easier and faster if not set when you have a if ($format) around the foreach.

Anushka-mp’s picture

Status: Needs work » Needs review
FileSize
1018 bytes
4.78 KB

check for the format moved two levels up, and comment added.

Berdir’s picture

Status: Needs review » Fixed

Thanks, looks good now.

  • Berdir committed 43744ed on 8.x-1.x authored by Anushka-mp
    Issue #2447421 by Anushka-mp: Expose text format of sources
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Berdir’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev
Status: Closed (fixed) » Patch (to be ported)

Changing status to possible backport.

It's not a priority on our side, but backporting this shouldn't be too hard and can be implemented in a very similar way in 7.x.