
| Current Path : /var/www/html_old/abk/web/modules/contrib/content_sync/src/Normalizer/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html_old/abk/web/modules/contrib/content_sync/src/Normalizer/ImageItemNormalizer.php |
<?php
namespace Drupal\content_sync\Normalizer;
use Drupal\image\Plugin\Field\FieldType\ImageItem;
use Drupal\serialization\Normalizer\EntityReferenceFieldItemNormalizer;
class ImageItemNormalizer extends EntityReferenceFieldItemNormalizer {
/**
* The interface or class that this Normalizer supports.
*
* @var string
*/
protected $supportedInterfaceOrClass = ImageItem::class;
/**
* {@inheritdoc}
*/
protected function constructValue($data, $context) {
$denormalized_data = parent::constructValue($data, $context);
foreach (['alt', 'title'] as $field) {
if(!empty($data[$field])) {
$denormalized_data[$field] = $data[$field];
}
}
return $denormalized_data;
}
}