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 aa4d19ac authored by Nicolas's avatar Nicolas
Browse files

Mise en place des ajustements fait en v1.5.12 sur les classes Pdf et Video

parent adc42134
No related branches found
No related tags found
No related merge requests found
......@@ -9,12 +9,14 @@ 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\Pdf as PdfModel;
use \NicolasBejean\MediaManager\Model\PdfRepository as PdfRepository;
use \NicolasBejean\MediaManager\Model\PdfFactory;
use \NicolasBejean\MediaManager\Model\Template\FilterProvider;
use \Magento\Framework\Serialize\Serializer\Json as JsonSerializer;
use \Exception;
use \Magento\Framework\Exception\LocalizedException;
/**
* Class Pdf for Widget
......@@ -45,10 +47,15 @@ class Pdf extends Template implements BlockInterface
protected $pdfFactory;
/**
* @var imageAdapterFactory
* @var ImageAdapterFactory
*/
protected $imageAdapterFactory;
/**
* @var PdfRepository
*/
protected $pdfRepository;
/**
* Store manager
*
......@@ -86,33 +93,28 @@ class Pdf extends Template implements BlockInterface
'backgroundColor' => null
];
/**
* @var JsonSerializer
*/
private $jsonSerializer;
/**
* @param Context $context
* @param FilterProvider $filterProvider
* @param PdfFactory $pdfFactory
* @param ImageAdapterFactory $imageAdapterFactory
* @param JsonSerializer $jsonSerializer
* @param PdfRepository $pdfRepository
* @param array $data
*/
public function __construct(
Context $context,
FilterProvider $filterProvider,
PdfFactory $pdfFactory,
imageAdapterFactory $imageAdapterFactory,
JsonSerializer $jsonSerializer,
ImageAdapterFactory $imageAdapterFactory,
PdfRepository $pdfRepository,
array $data = []
) {
$this->filterProvider = $filterProvider;
$this->pdfFactory = $pdfFactory;
$this->imageAdapterFactory = $imageAdapterFactory;
$this->pdfRepository = $pdfRepository;
$this->storeManager = $context->getStoreManager();
$this->filesystem = $context->getFilesystem();
$this->jsonSerializer = $jsonSerializer;
parent::__construct($context, $data);
}
......@@ -124,14 +126,18 @@ class Pdf extends Template implements BlockInterface
*/
public function getPdf()
{
/** @var PdfModel $pdf */
$pdf = $this->pdfFactory->create();
$pdf->load($this->getPdfId());
return $pdf;
try {
/** @var PdfModel $pdf */
$pdf = $this->pdfRepository->getById($this->getPdfId());
return $pdf;
} catch (LocalizedException $e) {
return null;
}
}
/**
* Récupère pdf_id
* Récupère l'ID du PDF
*/
public function getPdfId()
{
......@@ -154,7 +160,11 @@ class Pdf extends Template implements BlockInterface
public function getActiveTitle()
{
if ($this->getTitle() !== null) {
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_title')));
if ($this->getData('active_title') === 'true') {
return true;
}
return false;
}
return false;
......@@ -198,7 +208,11 @@ class Pdf extends Template implements BlockInterface
public function getActiveContent()
{
if ($this->getContent() !== null) {
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_content')));
if ($this->getData('active_content') === 'true') {
return true;
}
return false;
}
return false;
......@@ -281,7 +295,11 @@ class Pdf 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;
}
/**
......@@ -325,7 +343,11 @@ class Pdf extends Template implements BlockInterface
*/
public function getActiveImageBackground()
{
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_image_background')));
if ($this->getData('active_image_background') === 'true') {
return true;
}
return false;
}
/**
......@@ -349,7 +371,11 @@ class Pdf extends Template implements BlockInterface
*/
public function getActiveWrapper()
{
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_wrapper')));
if ($this->getData('active_wrapper') === 'true') {
return true;
}
return false;
}
/**
......@@ -472,8 +498,6 @@ class Pdf extends Template implements BlockInterface
$destination = $imageResized ;
$imageAdapter->save($destination);
$resizedURL = $baseURL . 'resized/' . $width . '/' . $image;
return $resizedURL;
return $baseURL . 'resized/' . $width . '/' . $image;
}
}
......@@ -9,12 +9,14 @@ 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\Template\FilterProvider;
use \NicolasBejean\MediaManager\Model\Video as VideoModel;
use \NicolasBejean\MediaManager\Model\VideoRepository as VideoRepository;
use \NicolasBejean\MediaManager\Model\VideoFactory;
use \Magento\Framework\Serialize\Serializer\Json as JsonSerializer;
use \Exception;
use \Magento\Framework\Exception\LocalizedException;
/**
* Class Video for Widget
......@@ -45,10 +47,15 @@ class Video extends Template implements BlockInterface
protected $videoFactory;
/**
* @var imageAdapterFactory
* @var ImageAdapterFactory
*/
protected $imageAdapterFactory;
/**
* @var VideoRepository
*/
protected $videoRepository;
/**
* Store manager
*
......@@ -86,33 +93,28 @@ class Video extends Template implements BlockInterface
'backgroundColor' => null
];
/**
* @var JsonSerializer
*/
private $jsonSerializer;
/**
* @param Context $context
* @param FilterProvider $filterProvider
* @param VideoFactory $videoFactory
* @param ImageAdapterFactory $imageAdapterFactory
* @param JsonSerializer $jsonSerializer
* @param VideoRepository $videoRepository
* @param array $data
*/
public function __construct(
Context $context,
FilterProvider $filterProvider,
VideoFactory $videoFactory,
imageAdapterFactory $imageAdapterFactory,
JsonSerializer $jsonSerializer,
ImageAdapterFactory $imageAdapterFactory,
VideoRepository $videoRepository,
array $data = []
) {
$this->filterProvider = $filterProvider;
$this->videoFactory = $videoFactory;
$this->imageAdapterFactory = $imageAdapterFactory;
$this->videoRepository = $videoRepository;
$this->storeManager = $context->getStoreManager();
$this->filesystem = $context->getFilesystem();
$this->jsonSerializer = $jsonSerializer;
parent::__construct($context, $data);
}
......@@ -124,14 +126,18 @@ class Video extends Template implements BlockInterface
*/
public function getVideo()
{
/** @var VideoModel $video */
$video = $this->videoFactory->create();
$video->load($this->getVideoId());
return $video;
try {
/** @var VideoModel $video */
$video = $this->videoRepository->getById($this->getVideoId());
return $video;
} catch (LocalizedException $e) {
return null;
}
}
/**
* Récupère video_id
* Récupère l'ID de la vidéo
*/
public function getVideoId()
{
......@@ -154,7 +160,11 @@ class Video extends Template implements BlockInterface
public function getActiveTitle()
{
if ($this->getTitle() !== null) {
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_title')));
if ($this->getData('active_title') === 'true') {
return true;
}
return false;
}
return false;
......@@ -198,7 +208,11 @@ class Video extends Template implements BlockInterface
public function getActiveContent()
{
if ($this->getContent() !== null) {
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_content')));
if ($this->getData('active_content') === 'true') {
return true;
}
return false;
}
return false;
......@@ -282,7 +296,11 @@ class Video extends Template implements BlockInterface
*/
public function getActiveControls()
{
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_controls')));
if ($this->getData('active_controls') === 'true') {
return true;
}
return false;
}
/**
......@@ -290,7 +308,11 @@ class Video extends Template implements BlockInterface
*/
public function getActiveAutoplay()
{
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_autoplay')));
if ($this->getData('active_autoplay') === 'true') {
return true;
}
return false;
}
/**
......@@ -298,7 +320,11 @@ class Video extends Template implements BlockInterface
*/
public function getActiveLoop()
{
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_loop')));
if ($this->getData('active_loop') === 'true') {
return true;
}
return false;
}
/**
......@@ -306,7 +332,11 @@ class Video extends Template implements BlockInterface
*/
public function getActivePreload()
{
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_preload')));
if ($this->getData('active_preload') === 'true') {
return true;
}
return false;
}
/**
......@@ -314,7 +344,11 @@ class Video extends Template implements BlockInterface
*/
public function getActiveSound()
{
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_sound')));
if ($this->getData('active_sound') === 'true') {
return true;
}
return false;
}
/**
......@@ -322,7 +356,11 @@ class Video extends Template implements BlockInterface
*/
public function getActivePoster()
{
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_poster')));
if ($this->getData('active_poster') === 'true') {
return true;
}
return false;
}
/**
......@@ -330,7 +368,11 @@ class Video 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;
}
/**
......@@ -382,7 +424,11 @@ class Video extends Template implements BlockInterface
*/
public function getActiveWrapper()
{
return (boolean)$this->jsonSerializer->unserialize(strtolower($this->getData('active_wrapper')));
if ($this->getData('active_wrapper') === 'true') {
return true;
}
return false;
}
/**
......@@ -503,8 +549,6 @@ class Video extends Template implements BlockInterface
$destination = $imageResized ;
$imageAdapter->save($destination);
$resizedURL = $baseURL . 'resized/' . $width . '/' . $image;
return $resizedURL;
return $baseURL . 'resized/' . $width . '/' . $image;
}
}
......@@ -4,22 +4,21 @@ use \NicolasBejean\MediaManager\Block\Widget\Pdf;
/* @var Pdf $block */
$pdfBlock = $block->getPdf();
$pdfPath = $block->getPath($pdfBlock->getData('pdf_path'));
$activePdf = $pdfBlock->getData('enabled');
$pdfPath = $pdfBlock->getPath();
$activePdf = $pdfBlock->isActive();
$activeWrapper = $block->getActiveWrapper();
$activeTitle = $block->getActiveTitle();
$activeContent = $block->getActiveContent();
$renderType = $block->getRenderType();
$imagePath = $pdfBlock->getData('image_path');
$imagePath = $pdfBlock->getImagePath();
$activeImageBackground = $block->getActiveImageBackground();
if ($imagePath != null):
try {
$image = $block->getResizeImage($imagePath, $block->getImageWidth(), $block->getImageHeight());
} catch (Exception $e) {
echo 'Aucune image';
}
endif;
?>
......@@ -64,4 +63,4 @@ endif;
<?php if ($activeWrapper): ?>
</div>
<?php endif; ?>
<?php endif; ?>
\ No newline at end of file
<?php endif; ?>
......@@ -4,14 +4,14 @@ use \NicolasBejean\MediaManager\Block\Widget\Video;
/* @var Video $block */
$videoBlock = $block->getVideo();
$videoPath = $block->getPath($videoBlock->getData('video_path'));
$videoPath = $videoBlock->getPath();
$activeVideo = $videoBlock->getData('enabled');
$activeVideo = $videoBlock->isActive();
$activeWrapper = $block->getActiveWrapper();
$activeTitle = $block->getActiveTitle();
$activeContent = $block->getActiveContent();
$imagePath = $videoBlock->getData('image_path');
$imagePath = $videoBlock->getImagePath();
if ($imagePath != null):
try {
......
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