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 /** * Copyright Magento, Inc. All rights reserved. * See COPYING.txt for license ..
Decoded Output download
<?php
/**
* Copyright Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Product description block
*
* @author Magento Core Team <[email protected]>
*/
namespace Magento\Catalog\Block\Product\View;
use Magento\Catalog\Model\Product;
use Magento\Framework\Phrase;
use Magento\Framework\Pricing\PriceCurrencyInterface;
/**
* Attributes attributes block
*
* @api
* @since 100.0.2
*/
class Attributes extends \Magento\Framework\View\Element\Template
{
/**
* @var Product
*/
protected $_product = null;
/**
* Core registry
*
* @var \Magento\Framework\Registry
*/
protected $_coreRegistry = null;
/**
* @var PriceCurrencyInterface
*/
protected $priceCurrency;
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Framework\Registry $registry
* @param PriceCurrencyInterface $priceCurrency
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\Registry $registry,
PriceCurrencyInterface $priceCurrency,
array $data = []
) {
$this->priceCurrency = $priceCurrency;
$this->_coreRegistry = $registry;
parent::__construct($context, $data);
}
/**
* Returns a Product
*
* @return Product
*/
public function getProduct()
{
if (!$this->_product) {
$this->_product = $this->_coreRegistry->registry('product');
}
return $this->_product;
}
/**
* $excludeAttr is optional array of attribute codes to exclude them from additional data array
*
* @param array $excludeAttr
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getAdditionalData(array $excludeAttr = [])
{
$data = [];
$product = $this->getProduct();
$attributes = $product->getAttributes();
foreach ($attributes as $attribute) {
if ($this->isVisibleOnFrontend($attribute, $excludeAttr)) {
$value = $attribute->getFrontend()->getValue($product);
if ($value instanceof Phrase) {
$value = (string)$value;
} elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
$value = $this->priceCurrency->convertAndFormat($value);
}
if (is_string($value) && strlen(trim($value))) {
$data[$attribute->getAttributeCode()] = [
'label' => $attribute->getStoreLabel(),
'value' => $value,
'code' => $attribute->getAttributeCode(),
];
}
}
}
return $data;
}
/**
* Determine if we should display the attribute on the front-end
*
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
* @param array $excludeAttr
* @return bool
* @since 103.0.0
*/
protected function isVisibleOnFrontend(
\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute,
array $excludeAttr
) {
return ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr));
}
}
?>
Did this file decode correctly?
Original Code
<?php
/**
* Copyright Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Product description block
*
* @author Magento Core Team <[email protected]>
*/
namespace Magento\Catalog\Block\Product\View;
use Magento\Catalog\Model\Product;
use Magento\Framework\Phrase;
use Magento\Framework\Pricing\PriceCurrencyInterface;
/**
* Attributes attributes block
*
* @api
* @since 100.0.2
*/
class Attributes extends \Magento\Framework\View\Element\Template
{
/**
* @var Product
*/
protected $_product = null;
/**
* Core registry
*
* @var \Magento\Framework\Registry
*/
protected $_coreRegistry = null;
/**
* @var PriceCurrencyInterface
*/
protected $priceCurrency;
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Framework\Registry $registry
* @param PriceCurrencyInterface $priceCurrency
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\Registry $registry,
PriceCurrencyInterface $priceCurrency,
array $data = []
) {
$this->priceCurrency = $priceCurrency;
$this->_coreRegistry = $registry;
parent::__construct($context, $data);
}
/**
* Returns a Product
*
* @return Product
*/
public function getProduct()
{
if (!$this->_product) {
$this->_product = $this->_coreRegistry->registry('product');
}
return $this->_product;
}
/**
* $excludeAttr is optional array of attribute codes to exclude them from additional data array
*
* @param array $excludeAttr
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getAdditionalData(array $excludeAttr = [])
{
$data = [];
$product = $this->getProduct();
$attributes = $product->getAttributes();
foreach ($attributes as $attribute) {
if ($this->isVisibleOnFrontend($attribute, $excludeAttr)) {
$value = $attribute->getFrontend()->getValue($product);
if ($value instanceof Phrase) {
$value = (string)$value;
} elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
$value = $this->priceCurrency->convertAndFormat($value);
}
if (is_string($value) && strlen(trim($value))) {
$data[$attribute->getAttributeCode()] = [
'label' => $attribute->getStoreLabel(),
'value' => $value,
'code' => $attribute->getAttributeCode(),
];
}
}
}
return $data;
}
/**
* Determine if we should display the attribute on the front-end
*
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
* @param array $excludeAttr
* @return bool
* @since 103.0.0
*/
protected function isVisibleOnFrontend(
\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute,
array $excludeAttr
) {
return ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr));
}
}
Function Calls
| None |
Stats
| MD5 | 4bb2bb1e2ea201b353d9e3f34e77adf0 |
| Eval Count | 0 |
| Decode Time | 78 ms |