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.
*/
namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
/**
* Backend grid item renderer currency
*
* @api
* @since 100.0.2
*/
class Currency extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
{
/**
* @var int
*/
protected $_defaultWidth = 100;
/**
* Currency objects cache
*
* @var \Magento\Framework\DataObject[]
*/
protected static $_currencies = [];
/**
* Application object
*
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $_storeManager;
/**
* @var \Magento\Directory\Model\Currency\DefaultLocator
*/
protected $_currencyLocator;
/**
* @var \Magento\Directory\Model\Currency
*/
protected $_defaultBaseCurrency;
/**
* @var \Magento\Framework\Locale\CurrencyInterface
*/
protected $_localeCurrency;
/**
* @param \Magento\Backend\Block\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Directory\Model\Currency\DefaultLocator $currencyLocator
* @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
* @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Directory\Model\Currency\DefaultLocator $currencyLocator,
\Magento\Directory\Model\CurrencyFactory $currencyFactory,
\Magento\Framework\Locale\CurrencyInterface $localeCurrency,
array $data = []
) {
parent::__construct($context, $data);
$this->_storeManager = $storeManager;
$this->_currencyLocator = $currencyLocator;
$this->_localeCurrency = $localeCurrency;
$defaultBaseCurrencyCode = $currencyLocator->getDefaultCurrency($this->_request);
$this->_defaultBaseCurrency = $currencyFactory->create()->load($defaultBaseCurrencyCode);
}
/**
* Renders grid column
*
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
{
if ($data = (string)$this->_getValue($row)) {
$currency_code = $this->_getCurrencyCode($row);
$data = (float)$data * $this->_getRate($row);
$sign = (bool)(int)$this->getColumn()->getShowNumberSign() && $data > 0 ? '+' : '';
$data = sprintf("%f", $data);
$data = $this->_localeCurrency->getCurrency($currency_code)->toCurrency($data);
return $sign . $data;
}
return $this->getColumn()->getDefault();
}
/**
* Returns currency code, false on error
*
* @param \Magento\Framework\DataObject $row
* @return string
*/
protected function _getCurrencyCode($row)
{
if ($code = $this->getColumn()->getCurrencyCode()) {
return $code;
}
$currency = $this->getColumn()->getCurrency();
if ($currency !== null && $code = $row->getData($currency)) {
return $code;
}
return $this->_currencyLocator->getDefaultCurrency($this->_request);
}
/**
* Get rate for current row, 1 by default
*
* @param \Magento\Framework\DataObject $row
* @return float|int
*/
protected function _getRate($row)
{
if ($rate = $this->getColumn()->getRate()) {
return (float) $rate;
}
$rateField = $this->getColumn()->getRateField();
if ($rateField !== null && $rate = $row->getData($rateField)) {
return (float) $rate;
}
return $this->_defaultBaseCurrency->getRate($this->_getCurrencyCode($row));
}
/**
* Returns HTML for CSS
*
* @return string
*/
public function renderCss()
{
return parent::renderCss() . ' a-right';
}
}
?>
Did this file decode correctly?
Original Code
<?php
/**
* Copyright Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
/**
* Backend grid item renderer currency
*
* @api
* @since 100.0.2
*/
class Currency extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
{
/**
* @var int
*/
protected $_defaultWidth = 100;
/**
* Currency objects cache
*
* @var \Magento\Framework\DataObject[]
*/
protected static $_currencies = [];
/**
* Application object
*
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $_storeManager;
/**
* @var \Magento\Directory\Model\Currency\DefaultLocator
*/
protected $_currencyLocator;
/**
* @var \Magento\Directory\Model\Currency
*/
protected $_defaultBaseCurrency;
/**
* @var \Magento\Framework\Locale\CurrencyInterface
*/
protected $_localeCurrency;
/**
* @param \Magento\Backend\Block\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Directory\Model\Currency\DefaultLocator $currencyLocator
* @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
* @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Directory\Model\Currency\DefaultLocator $currencyLocator,
\Magento\Directory\Model\CurrencyFactory $currencyFactory,
\Magento\Framework\Locale\CurrencyInterface $localeCurrency,
array $data = []
) {
parent::__construct($context, $data);
$this->_storeManager = $storeManager;
$this->_currencyLocator = $currencyLocator;
$this->_localeCurrency = $localeCurrency;
$defaultBaseCurrencyCode = $currencyLocator->getDefaultCurrency($this->_request);
$this->_defaultBaseCurrency = $currencyFactory->create()->load($defaultBaseCurrencyCode);
}
/**
* Renders grid column
*
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
{
if ($data = (string)$this->_getValue($row)) {
$currency_code = $this->_getCurrencyCode($row);
$data = (float)$data * $this->_getRate($row);
$sign = (bool)(int)$this->getColumn()->getShowNumberSign() && $data > 0 ? '+' : '';
$data = sprintf("%f", $data);
$data = $this->_localeCurrency->getCurrency($currency_code)->toCurrency($data);
return $sign . $data;
}
return $this->getColumn()->getDefault();
}
/**
* Returns currency code, false on error
*
* @param \Magento\Framework\DataObject $row
* @return string
*/
protected function _getCurrencyCode($row)
{
if ($code = $this->getColumn()->getCurrencyCode()) {
return $code;
}
$currency = $this->getColumn()->getCurrency();
if ($currency !== null && $code = $row->getData($currency)) {
return $code;
}
return $this->_currencyLocator->getDefaultCurrency($this->_request);
}
/**
* Get rate for current row, 1 by default
*
* @param \Magento\Framework\DataObject $row
* @return float|int
*/
protected function _getRate($row)
{
if ($rate = $this->getColumn()->getRate()) {
return (float) $rate;
}
$rateField = $this->getColumn()->getRateField();
if ($rateField !== null && $rate = $row->getData($rateField)) {
return (float) $rate;
}
return $this->_defaultBaseCurrency->getRate($this->_getCurrencyCode($row));
}
/**
* Returns HTML for CSS
*
* @return string
*/
public function renderCss()
{
return parent::renderCss() . ' a-right';
}
}
Function Calls
None |
Stats
MD5 | 800508f499569fe6da6560b989482e08 |
Eval Count | 0 |
Decode Time | 95 ms |