Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/app/code/Kaliop/Core/Model/Import/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/app/code/Kaliop/Core/Model/Import/AbstractImport.php
<?php

declare(strict_types=1);

namespace Kaliop\Core\Model\Import;

use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Filesystem\Driver\File;
use Magento\Framework\Module\Dir;
use Magento\Framework\Module\Dir\Reader;
use Magento\Framework\Phrase;

abstract class AbstractImport
{
    /** @var File */
    protected $fileSystem;

    /** @var DirectoryList */
    protected $directoryList;

    /** @var Reader */
    protected $moduleReader;

    public function __construct(
        File $fileSystem,
        DirectoryList $directoryList,
        Reader $moduleReader
    ) {
        $this->fileSystem = $fileSystem;
        $this->directoryList = $directoryList;
        $this->moduleReader = $moduleReader;
    }

    /**
     * @param string $filename
     * @param string $moduleName
     * @return resource
     * @throws LocalizedException
     */
    public function openFile(string $moduleName, string $filename)
    {
        $filePath = $this->moduleReader->getModuleDir(Dir::MODULE_ETC_DIR, $moduleName) . '/data/' . $filename;
        $handle = $this->fileSystem->fileOpen($filePath, 'r');

        if (!$handle) {
            throw new LocalizedException(new Phrase('Unable to open %1 file', [$filename]));
        }

        return $handle;
    }
}

Spamworldpro Mini