- 🇵🇱Poland lamp5 Rzeszow
The problem is that your text filter is missing in ACH, you have to process your data during unserialize process to attach your local text filter.
<?php namespace Drupal\mymodule\EventSubscriber\UnserializeContentField; use Drupal\acquia_contenthub\AcquiaContentHubEvents; use Drupal\acquia_contenthub\Event\UnserializeCdfEntityFieldEvent; use Drupal\acquia_contenthub\EventSubscriber\UnserializeContentField\FieldEntityReferenceBase; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Manual handling for text item fields filter references. */ class TextItemFieldWithFilter extends FieldEntityReferenceBase implements EventSubscriberInterface { /** * Field types to unserialize. * * @var array */ protected $fieldTypes = ['text_with_summary', 'text', 'text_long']; /** * {@inheritdoc} */ public static function getSubscribedEvents() { $events[AcquiaContentHubEvents::UNSERIALIZE_CONTENT_ENTITY_FIELD] = ['onUnserializeContentField', 101]; return $events; } /** * {@inheritdoc} */ public function onUnserializeContentField(UnserializeCdfEntityFieldEvent $event) { if (!in_array($event->getFieldMetadata()['type'], $this->fieldTypes)) { return; } $field = $event->getField(); $values = []; // Return early if no attr values are set. if (empty($field['value'])) { return; } foreach ($field['value'] as $langcode => $value) { foreach ($value as &$item) { if (!$item['format']) { continue; } $filter = $this->getFilter($item['format']); if (!$filter) { $this->log($item['format']); $item['format'] = filter_fallback_format(); } $item['format'] = $filter->id(); } $values[$langcode][$event->getFieldName()] = $value; } $event->setValue($values); $event->stopPropagation(); } /** * Get filter. * * @param string $uuid * Filter uuid. * * @return \Drupal\filter\Entity\FilterFormat|null * Filter format. */ protected function getFilter(string $uuid) { $storage = \Drupal::entityTypeManager()->getStorage('filter_format'); $entities = $storage->loadByProperties(['uuid' => $uuid]); return !empty($entities) ? reset($entities) : NULL; } }
- Status changed to Fixed
4 months ago 8:59am 26 September 2024 - 🇮🇳India n4r3n Goa
This issue is already fixed in 3.x branch. Since Acquia Content Hub 2.x will reach end-of-life on 31 December 2024, there won't be any new features or bug fixes for 2.x branch. Please upgrade to 3.x branch for latest features and bug fixes.
Automatically closed - issue fixed for 2 weeks with no activity.