Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 1ab80c0a authored by Nicolas's avatar Nicolas
Browse files

### Added

- Ajout de la dépendance à Magento_Widget
- Mise en place de la classe ImageRepository pour supprimer le load (deprecated)
### Changed
- Corrections de l'orthographe de la classe ImageAdapterFactory
### Deleted
- Suppression de la classe JsonSerializer et modification du traitement des valeurs en booléen
- Supression d'une variable dnas le return d'une fonction
parent 07b144a1
No related branches found
No related tags found
No related merge requests found
......@@ -9,12 +9,15 @@ use \Magento\Store\Model\StoreManagerInterface;
use \Magento\Widget\Block\BlockInterface;
use \Magento\Framework\UrlInterface;
use \Magento\Framework\App\Filesystem\DirectoryList;
use \Magento\Framework\Image\AdapterFactory as imageAdapterFactory;
use \Magento\Framework\Image\AdapterFactory as ImageAdapterFactory;
use \NicolasBejean\MediaManager\Model\Image as ImageModel;
use \NicolasBejean\MediaManager\Model\ImageRepository as ImageRepository;
use \NicolasBejean\MediaManager\Model\ImageFactory;
use \NicolasBejean\MediaManager\Model\Template\FilterProvider;
use \Magento\Framework\Serialize\Serializer\Json as JsonSerializer;
use \Exception;
use \Magento\Framework\Exception\LocalizedException;
/**
* Class Image for Widget
......@@ -45,10 +48,15 @@ class Image extends Template implements BlockInterface
protected $imageFactory;
/**
* @var imageAdapterFactory
* @var ImageAdapterFactory
*/
protected $imageAdapterFactory;
/**
* @var ImageRepository
*/
protected $imageRepository;
/**
* Store manager
*
......@@ -98,33 +106,28 @@ class Image extends Template implements BlockInterface
320, 480, 640, 800, 960, 1120, 1280, 1440, 1600, 1920, 2560, 3040, 3840
];
/**
* @var JsonSerializer
*/
private $jsonSerializer;
/**
* @param Context $context
* @param FilterProvider $filterProvider
* @param ImageFactory $imageFactory
* @param ImageAdapterFactory $imageAdapterFactory
* @param JsonSerializer $jsonSerializer
* @param ImageRepository $imageRepository
* @param array $data
*/
public function __construct(
Context $context,
FilterProvider $filterProvider,
ImageFactory $imageFactory,
imageAdapterFactory $imageAdapterFactory,
JsonSerializer $jsonSerializer,
ImageAdapterFactory $imageAdapterFactory,
ImageRepository $imageRepository,
array $data = []
) {
$this->filterProvider = $filterProvider;
$this->imageFactory = $imageFactory;
$this->imageAdapterFactory = $imageAdapterFactory;
$this->imageRepository = $imageRepository;
$this->storeManager = $context->getStoreManager();
$this->filesystem = $context->getFilesystem();
$this->jsonSerializer = $jsonSerializer;
parent::__construct($context, $data);
}
......@@ -136,10 +139,14 @@ class Image extends Template implements BlockInterface
*/
public function getImage()
{
/** @var ImageModel $image */
$image = $this->imageFactory->create();
$image->load($this->getImageId());
return $image;
try {
/** @var ImageModel $image */
$image = $this->imageRepository->getById($this->getImageId());
return $image;
} catch (LocalizedException $e) {
return null;
}
}
/**
......@@ -156,7 +163,11 @@ class Image extends Template implements BlockInterface
public function getActiveTitle()
{
if ($this->getWidgetTitle() !== null) {
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_title')));
if ($this->getData('active_title') === 'true') {
return true;
}
return false;
}
return false;
......@@ -192,7 +203,11 @@ class Image extends Template implements BlockInterface
public function getActiveContent()
{
if ($this->getWidgetContent() !== null) {
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_content')));
if ($this->getData('active_content') === 'true') {
return true;
}
return false;
}
return false;
......@@ -219,7 +234,11 @@ class Image extends Template implements BlockInterface
*/
public function getActiveResize()
{
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('image_active_resize')));
if ($this->getData('image_active_resize') === 'true') {
return true;
}
return false;
}
/**
......@@ -263,7 +282,11 @@ class Image extends Template implements BlockInterface
*/
public function getActiveResponsiveImage()
{
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('image_active_responsive_image')));
if ($this->getData('image_active_responsive_image') === 'true') {
return true;
}
return false;
}
/**
......@@ -295,7 +318,11 @@ class Image extends Template implements BlockInterface
*/
public function getActiveImageBackground()
{
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('image_active_image_background')));
if ($this->getData('image_active_image_background') === 'true') {
return true;
}
return false;
}
/**
......@@ -303,7 +330,11 @@ class Image extends Template implements BlockInterface
*/
public function getActiveImageWrapper()
{
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_image_wrapper')));
if ($this->getData('active_image_wrapper') === 'true') {
return true;
}
return false;
}
/**
......@@ -319,7 +350,11 @@ class Image extends Template implements BlockInterface
*/
public function getActiveLink()
{
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('image_active_link')));
if ($this->getData('image_active_link') === 'true') {
return true;
}
return false;
}
/**
......@@ -442,9 +477,7 @@ class Image extends Template implements BlockInterface
$destination = $imageResized ;
$imageAdapter->save($destination);
$resizedURL = $baseURL . 'resized/' . $width . '/' . $image;
return $resizedURL;
return $baseURL . 'resized/' . $width . '/' . $image;
}
/**
......
# Changelog
## [1.5.12] - 2020-04-16
### Added
- Ajout de la dépendance à Magento_Widget
- Mise en place de la classe ImageRepository pour supprimer le load (deprecated)
### Changed
- Corrections de l'orthographe de la classe ImageAdapterFactory
### Deleted
- Suppression de la classe JsonSerializer et modification du traitement des valeurs en booléen
- Supression d'une variable dnas le return d'une fonction
## [1.5.11] - 2019-11-17
### Changed
- Corrections de la variable template dans les widgets
......
......@@ -2,10 +2,11 @@
"name": "nicolasbejean/mediamanager",
"description": "Gestionnaire de médias",
"type": "magento2-module",
"version": "1.5.11",
"version": "1.5.12",
"require": {
"php": ">=7.0.0",
"nicolasbejean/base": ">=1.0.0"
"php": "~7.1.3||~7.2.0||~7.3.0",
"magento/module-widget": "101.0.*",
"nicolasbejean/base": "1.0.*"
},
"license": [
"OSL-3.0",
......
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="NicolasBejean_MediaManager" setup_version="1.5.11">
<module name="NicolasBejean_MediaManager" setup_version="1.5.12">
<sequence>
<module name="Magento_Widget" />
<module name="NicolasBejean_Base"/>
</sequence>
</module>
......
......@@ -4,8 +4,8 @@ use \NicolasBejean\MediaManager\Block\Widget\Image;
/* @var Image $block */
$imageBlock = $block->getImage();
$imagePath = $imageBlock->getData('image_path');
$activeImage = $imageBlock->getData('enabled');
$imagePath = $imageBlock->getPath();
$activeImage = $imageBlock->isActive();
$activeTitle = $block->getActiveTitle();
$activeContent = $block->getActiveContent();
$activeResponsiveImage = $block->getActiveResponsiveImage();
......@@ -76,4 +76,4 @@ endif;
<?php if ($activeImageWrapper): ?>
</div>
<?php endif; ?>
<?php endif; ?>
\ No newline at end of file
<?php endif; ?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment