![]() 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/Cnc/Theme/ViewModel/ |
<?php /** * Copyright (c) 2019 Kaliop Digital Commerce (https://digitalcommerce.kaliop.com) All Rights Reserved. * https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * cnc_theme_m2 * <[email protected]> */ declare(strict_types=1); namespace Cnc\Theme\ViewModel; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\DataObject; use Magento\Framework\Filter\FilterManager; use Magento\Framework\View\Element\Block\ArgumentInterface; use Magento\Store\Model\ScopeInterface; class Utils extends DataObject implements ArgumentInterface { /** * @var ScopeConfigInterface */ private $scopeConfig; /** * Filter manager * @var FilterManager */ private $filterManager; /** * Utils constructor. * * @param ScopeConfigInterface $scopeConfig * @param FilterManager $filterManager * @param array $data */ public function __construct( ScopeConfigInterface $scopeConfig, FilterManager $filterManager, array $data = [] ) { parent::__construct($data); $this->scopeConfig = $scopeConfig; $this->filterManager = $filterManager; } /** * @param $configPath * @param string $storeScope * * @return string */ public function getScopeConfigValue($configPath, $storeScope = ScopeInterface::SCOPE_STORES): string { return (string)$this->scopeConfig->getValue($configPath, $storeScope); } /** * Truncate string * * @param string $value * @param int $length * @param string $etc * @param string &$remainder * @param bool $breakWords * * @return string */ public function truncateString( $value, $length = 80, $etc = '...', &$remainder = '', $breakWords = true ): string { return $this->filterManager->truncate( $value, ['length' => $length, 'etc' => $etc, 'remainder' => $remainder, 'breakWords' => $breakWords] ); } }