Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/magento/module-catalog/Model/Product/Gallery/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-catalog/Model/Product/Gallery/EntryResolver.php
<?php
/**
 * Product Media Gallery Entry Resolver
 *
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Catalog\Model\Product\Gallery;

use Magento\Catalog\Model\Product;

/**
 * Manage entryes
 */
class EntryResolver
{
    /**
     * Retrieve file path that corresponds to the given gallery entry ID
     *
     * @param Product $product
     * @param int $entryId
     * @return string|null
     */
    public function getEntryFilePathById(Product $product, $entryId)
    {
        $mediaGalleryData = $product->getData('media_gallery');
        if (!isset($mediaGalleryData['images']) || !is_array($mediaGalleryData['images'])) {
            return null;
        }

        foreach ($mediaGalleryData['images'] as $image) {
            if (isset($image['value_id']) && $image['value_id'] == $entryId) {
                return $image['file'] ?? null;
            }
        }
        return null;
    }

    /**
     * Retrieve gallery entry ID that corresponds to the given file path
     *
     * @param Product $product
     * @param string $filePath
     * @return int|null
     */
    public function getEntryIdByFilePath(Product $product, $filePath)
    {
        $mediaGalleryData = $product->getData('media_gallery');
        if (!isset($mediaGalleryData['images']) || !is_array($mediaGalleryData['images'])) {
            return null;
        }

        foreach ($mediaGalleryData['images'] as $image) {
            if (isset($image['file']) && $image['file'] == $filePath) {
                return $image['value_id'] ?? null;
            }
        }
        return null;
    }
}

Spamworldpro Mini