35. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2020-08-14 00:01:31 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

35.1 Files compared

#LocationFileLast Modified
12020-08-14 00:01:31 +0000
2Porto v3.2.4/Magento 2.x/Porto Theme/app/code/Mageplaza/LayeredNavigation/HelperImage.php2020-06-26 11:11:14 +0000

35.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged00
Changed00
Inserted1158
Removed00

35.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

35.4 Active regular expressions

No regular expressions were active.

35.5 Comparison detail

    1 <?php
    2 /**
    3  * Mageplaza
    4  *
    5  * NOTICE OF LICENSE
    6  *
    7  * This source file is subject to the Mageplaza.com license that is
    8  * available through the world-wide-web at this URL:
    9  * https://www.mageplaza.com/LICENSE.txt
    10  *
    11  * DISCLAIMER
    12  *
    13  * Do not edit or add to this file if you wish to upgrade this extension to newer
    14  * version in the future.
    15  *
    16  * @category    Mageplaza
    17  * @package     Mageplaza_LayeredNavigation
    18  * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/)
    19  * @license     https://www.mageplaza.com/LICENSE.txt
    20  */
    21 
    22 namespace Mageplaza\LayeredNavigation\Helper;
    23 
    24 use Exception;
    25 use Magento\Catalog\Model\Layer\Filter\FilterInterface;
    26 use Magento\Framework\App\Helper\Context;
    27 use Magento\Framework\Exception\FileSystemException;
    28 use Magento\Framework\Exception\LocalizedException;
    29 use Magento\Framework\Filesystem;
    30 use Magento\Framework\Image\AdapterFactory;
    31 use Magento\Framework\ObjectManagerInterface;
    32 use Magento\Framework\View\Asset\Repository;
    33 use Magento\MediaStorage\Model\File\UploaderFactory;
    34 use Magento\Store\Model\StoreManagerInterface;
    35 use Mageplaza\Core\Helper\Media;
    36 
    37 /**
    38  * Class Image
    39  * @package Mageplaza\LayeredNavigation\Helper
    40  */
    41 class Image extends Media
    42 {
    43     const TEMPLATE_MEDIA_PATH    = 'mageplaza/layernavigation';
    44     const TOOLTIP_THUMBNAIL_PATH = 'tooltip/thumbnail';
    45 
    46     /**
    47      * @var Repository
    48      */
    49     protected $_assetRepo;
    50 
    51     /**
    52      * Image constructor.
    53      *
    54      * @param Context $context
    55      * @param ObjectManagerInterface $objectManager
    56      * @param StoreManagerInterface $storeManager
    57      * @param Filesystem $filesystem
    58      * @param UploaderFactory $uploaderFactory
    59      * @param AdapterFactory $imageFactory
    60      * @param Repository $assetRepo
    61      *
    62      * @throws FileSystemException
    63      */
    64     public function __construct(
    65         Context $context,
    66         ObjectManagerInterface $objectManager,
    67         StoreManagerInterface $storeManager,
    68         Filesystem $filesystem,
    69         UploaderFactory $uploaderFactory,
    70         AdapterFactory $imageFactory,
    71         Repository $assetRepo
    72     ) {
    73         $this->_assetRepo = $assetRepo;
    74         parent::__construct($context, $objectManager, $storeManager, $filesystem, $uploaderFactory, $imageFactory);
    75     }
    76 
    77     /**
    78      * @param $data
    79      * @param string $fileName
    80      * @param null $oldImage
    81      *
    82      * @return $this|Media
    83      * @throws FileSystemException
    84      */
    85     public function uploadThumbnail(&$data, $fileName = 'image', $oldImage = null)
    86     {
    87         $type = self::TOOLTIP_THUMBNAIL_PATH;
    88         if (isset($data[$fileName]) && isset($data[$fileName]['delete']) && $data[$fileName]['delete']) {
    89             if ($oldImage) {
    90                 $this->removeImage($oldImage, $type);
    91             }
    92             $data[$fileName] = '';
    93         } else {
    94             try {
    95                 $uploader = $this->uploaderFactory->create(['fileId' => $fileName]);
    96                 $uploader->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png']);
    97                 $uploader->setAllowRenameFiles(true);
    98                 $uploader->setFilesDispersion(true);
    99                 $uploader->setAllowCreateFolders(true);
    100 
    101                 $path = $this->getBaseMediaPath($type);
    102 
    103                 $image = $uploader->save(
    104                     $this->mediaDirectory->getAbsolutePath($path)
    105                 );
    106 
    107                 if ($oldImage) {
    108                     $this->removeImage($oldImage, $type);
    109                 }
    110 
    111                 $data[$fileName] = $this->_prepareFile($image['file']);
    112             } catch (Exception $e) {
    113                 $this->_logger->critical($e);
    114                 $data[$fileName] = isset($data[$fileName]['value']) ? $data[$fileName]['value'] : '';
    115             }
    116         }
    117 
    118         return $this;
    119     }
    120 
    121     /**
    122      * @param $value
    123      *
    124      * @return string
    125      */
    126     public function getImageSrc($value)
    127     {
    128         $src = $this->getMediaPath($value, self::TOOLTIP_THUMBNAIL_PATH);
    129         if (!preg_match("/^http\:\/\/|https\:\/\//", $src)) {
    130             $src = $this->getMediaUrl($src);
    131         }
    132 
    133         return $src;
    134     }
    135 
    136     /**
    137      * @param FilterInterface $filter
    138      *
    139      * @return string
    140      */
    141     public function getTooltipThumbnail($filter)
    142     {
    143         $url = '';
    144         try {
    145             $thumbnail = $filter->getAttributeModel()->getData('tooltip_thumbnail');
    146 
    147             if ($thumbnail) {
    148                 $url = $this->getImageSrc($thumbnail);
    149             } else {
    150                 $url = $this->_assetRepo->getUrl('Mageplaza_LayeredNavigation::css/images/tooltip.svg');
    151             }
    152         } catch (LocalizedException $e) {
    153             $this->_logger->error($e);
    154         }
    155 
    156         return $url;
    157     }
    158 }