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

Replace pathinfo() par getPathInfo() de Magento

parent 5cd579b7
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ use \Magento\Framework\View\Element\Template\Context;
use \Magento\Store\Model\ScopeInterface;
use \Magento\Store\Model\StoreManagerInterface;
use \Magento\Widget\Block\BlockInterface;
use \Magento\Framework\Filesystem\Io\File;
use \NicolasBejean\Base\Helper\ImageOptimizer;
......@@ -69,6 +70,11 @@ class ContentManager extends Template implements BlockInterface
*/
protected $filesystem;
/**
* @var File
*/
protected $file;
/**
* @var array
*/
......@@ -103,6 +109,7 @@ class ContentManager extends Template implements BlockInterface
* @param ContentManagerRepository $contentManagerRepository
* @param ImageOptimizer $imageOptimizer
* @param ImageAdapterFactory $imageAdapterFactory
* @param File $file
* @param array $data
*/
public function __construct(
......@@ -112,10 +119,12 @@ class ContentManager extends Template implements BlockInterface
ContentManagerRepository $contentManagerRepository,
ImageOptimizer $imageOptimizer,
ImageAdapterFactory $imageAdapterFactory,
File $file,
array $data = []
) {
$this->storeManager = $context->getStoreManager();
$this->filesystem = $context->getFilesystem();
$this->file = $file;
$this->filterProvider = $filterProvider;
$this->contentManagerFactory = $contentManagerFactory;
......@@ -469,7 +478,7 @@ class ContentManager extends Template implements BlockInterface
public function getResizeImage($image, $width = null, $height = null, array $settings = [])
{
/* Retourne des informations sur un chemin système d'un fichier */
$fileInfo = pathinfo($image);
$fileInfo = $this->file->getPathInfo($image);
/* Définit l'extension du fichier */
$extension = $fileInfo['extension'];
......
......@@ -6,6 +6,7 @@ use \NicolasBejean\ContentManager\Model\ResourceModel\ContentManager\Collection;
use \NicolasBejean\ContentManager\Model\ResourceModel\ContentManager\CollectionFactory;
use \Magento\Framework\App\Request\DataPersistorInterface;
use \Magento\Ui\DataProvider\AbstractDataProvider;
use \Magento\Framework\Filesystem\Io\File;
/**
* Class DataProvider
......@@ -33,16 +34,22 @@ class DataProvider extends AbstractDataProvider
*/
protected $loadedData;
/**
* @var File
*/
protected $file;
/**
* Constructor
*
* @param string $name
* @param string $primaryFieldName
* @param string $requestFieldName
* @param CollectionFactory $contentManagerCollectionFactory
* @param DataPersistorInterface $dataPersistor
* @param array $meta
* @param array $data
* @param string $name
* @param string $primaryFieldName
* @param string $requestFieldName
* @param CollectionFactory $contentManagerCollectionFactory
* @param DataPersistorInterface $dataPersistor
* @param File $file
* @param array $meta
* @param array $data
*/
public function __construct(
string $name,
......@@ -50,11 +57,13 @@ class DataProvider extends AbstractDataProvider
string $requestFieldName,
CollectionFactory $contentManagerCollectionFactory,
DataPersistorInterface $dataPersistor,
File $file,
array $meta = [],
array $data = []
) {
$this->collection = $contentManagerCollectionFactory->create();
$this->dataPersistor = $dataPersistor;
$this->file = $file;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
}
......@@ -76,7 +85,7 @@ class DataProvider extends AbstractDataProvider
if ($contentManager->getImagePath()) {
/* Retourne des informations sur un chemin système d'un fichier */
$fileInfo = pathinfo($contentManager->getImagePath());
$fileInfo = $this->file->getPathInfo($contentManager->getImagePath());
/* Définit le nom du fichier */
$m['image_path'][0]['name'] = $fileInfo['basename'];
......
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