Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /** * Product Media Gallery Entry Resolver * * Copyright Magento, Inc. All right..
Decoded Output download
<?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;
}
}
?>
Did this file decode correctly?
Original Code
<?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;
}
}
Function Calls
None |
Stats
MD5 | 72ea2cbeaaf23d34addeb35853f2128a |
Eval Count | 0 |
Decode Time | 147 ms |