* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler; use PrestaShop\PrestaShop\Core\Domain\Theme\Command\AdaptThemeToRTLLanguagesCommand; use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\CannotAdaptThemeToRTLLanguagesException; use PrestaShop\PrestaShop\Core\Localization\RTL\Exception\GenerationException; use PrestaShop\PrestaShop\Core\Localization\RTL\StyleSheetProcessorFactoryInterface; /** * Class AdaptThemeToRTLLanguagesHandler */ final class AdaptThemeToRTLLanguagesHandler implements AdaptThemeToRTLLanguagesHandlerInterface { /** * @var StyleSheetProcessorFactoryInterface */ private $stylesheetProcessorFactory; /** * @param StyleSheetProcessorFactoryInterface $stylesheetProcessorFactory */ public function __construct(StyleSheetProcessorFactoryInterface $stylesheetProcessorFactory) { $this->stylesheetProcessorFactory = $stylesheetProcessorFactory; } /** * {@inheritdoc} */ public function handle(AdaptThemeToRTLLanguagesCommand $command) { $plainThemeName = $command->getThemeName()->getValue(); try { $this->stylesheetProcessorFactory ->create() ->setProcessFOThemes([$plainThemeName]) ->process() ; } catch (GenerationException $e) { throw new CannotAdaptThemeToRTLLanguagesException(sprintf('Cannot adapt "%s" theme to RTL languages.', $plainThemeName), 0, $e); } } }