Your IP : 216.73.216.97


Current Path : /var/www/clients/client3/web2/web/vendor/magento/module-adobe-stock-image/Model/
Upload File :
Current File : /var/www/clients/client3/web2/web/vendor/magento/module-adobe-stock-image/Model/SerializeImage.php

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\AdobeStockImage\Model;

use Magento\Framework\Api\AttributeInterface;
use Magento\Framework\Api\Search\Document;

/**
 * Class used to serialize a Document object
 */
class SerializeImage
{
    /**
     * Serializes a Document object
     *
     * @param Document $image
     * @return array
     */
    public function execute(Document $image): array
    {
        $data = [];
        /** @var AttributeInterface $attribute */
        foreach ($image->getCustomAttributes() as $attribute) {
            if ($attribute->getAttributeCode() === 'thumbnail_240_url') {
                $data['thumbnail_url'] = $attribute->getValue();
                continue;
            }
            $data[$attribute->getAttributeCode()] = $attribute->getValue();
        }
        return $data;
    }
}