change getting file manager option

This commit is contained in:
Daniel Seifert 2024-12-04 11:44:22 +01:00
parent 950a5f0e7d
commit 5c5101525f
3 changed files with 40 additions and 4 deletions

View File

@ -24,8 +24,14 @@ declare(strict_types=1);
namespace O3\TinyMCE\Application\Core\TinyMCE\Options; namespace O3\TinyMCE\Application\Core\TinyMCE\Options;
use O3\TinyMCE\Application\Core\TinyMCE\Loader; use O3\TinyMCE\Application\Core\TinyMCE\Loader;
use O3\TinyMCE\Application\Model\Constants;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\UtilsServer; use OxidEsales\Eshop\Core\UtilsServer;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class FilemanagerUrl extends AbstractOption class FilemanagerUrl extends AbstractOption
{ {
@ -36,7 +42,7 @@ class FilemanagerUrl extends AbstractOption
public function get(): string public function get(): string
{ {
/** @var string $sFilemanagerKey */ /** @var string $sFilemanagerKey */
$sFilemanagerKey = md5_file(Registry::getConfig()->getConfigParam("sShopDir")."/config.inc.php"); $sFilemanagerKey = md5_file(rtrim(Registry::getConfig()->getConfigParam("sShopDir"), '/')."/config.inc.php");
Registry::get(UtilsServer::class)->setOxCookie("filemanagerkey", $sFilemanagerKey); Registry::get(UtilsServer::class)->setOxCookie("filemanagerkey", $sFilemanagerKey);
return str_replace( return str_replace(
@ -56,6 +62,12 @@ class FilemanagerUrl extends AbstractOption
*/ */
public function requireRegistration(): bool public function requireRegistration(): bool
{ {
return (bool) $this->loader->getShopConfig()->getConfigParam("blTinyMCE_filemanager"); try {
/** @var ModuleSettingService $service */
$service = ContainerFactory::getInstance()->getContainer()->get( ModuleSettingServiceInterface::class );
return $service->getBoolean( "blTinyMCE_filemanager", Constants::OXID_MODULE_ID );
} catch (ContainerExceptionInterface|NotFoundExceptionInterface) {
return false;
}
} }
} }

View File

@ -24,6 +24,12 @@ declare(strict_types=1);
namespace O3\TinyMCE\Application\Core\TinyMCE\Options; namespace O3\TinyMCE\Application\Core\TinyMCE\Options;
use O3\TinyMCE\Application\Core\TinyMCE\Utils; use O3\TinyMCE\Application\Core\TinyMCE\Utils;
use O3\TinyMCE\Application\Model\Constants;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class Setup extends AbstractOption class Setup extends AbstractOption
{ {
@ -45,6 +51,12 @@ class Setup extends AbstractOption
*/ */
public function requireRegistration(): bool public function requireRegistration(): bool
{ {
return (bool) $this->loader->getShopConfig()->getConfigParam("blTinyMCE_filemanager"); try {
/** @var ModuleSettingService $service */
$service = ContainerFactory::getInstance()->getContainer()->get( ModuleSettingServiceInterface::class );
return $service->getBoolean( "blTinyMCE_filemanager", Constants::OXID_MODULE_ID );
} catch (ContainerExceptionInterface|NotFoundExceptionInterface) {
return false;
}
} }
} }

View File

@ -23,8 +23,14 @@ declare(strict_types=1);
namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins;
use O3\TinyMCE\Application\Model\Constants;
use OxidEsales\Eshop\Core\Exception\FileException; use OxidEsales\Eshop\Core\Exception\FileException;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class Roxy extends AbstractPlugin class Roxy extends AbstractPlugin
{ {
@ -52,6 +58,12 @@ class Roxy extends AbstractPlugin
public function requireScript(): bool public function requireScript(): bool
{ {
return (bool) Registry::getConfig()->getConfigParam("blTinyMCE_filemanager"); try {
/** @var ModuleSettingService $service */
$service = ContainerFactory::getInstance()->getContainer()->get( ModuleSettingServiceInterface::class );
return $service->getBoolean( "blTinyMCE_filemanager", Constants::OXID_MODULE_ID );
} catch (ContainerExceptionInterface|NotFoundExceptionInterface) {
return false;
}
} }
} }