Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
DesignExceptions Class Reference

Public Member Functions

 __construct (\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, $exceptionConfigPath, $scopeType, Json $serializer=null)
 
 getThemeByRequest (\Magento\Framework\App\Request\Http $request)
 

Protected Attributes

 $scopeConfig
 
 $exceptionConfigPath
 
 $scopeType
 

Detailed Description

Class DesignExceptions

Definition at line 14 of file DesignExceptions.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\App\Config\ScopeConfigInterface  $scopeConfig,
  $exceptionConfigPath,
  $scopeType,
Json  $serializer = null 
)

DesignExceptions constructor

Parameters
\Magento\Framework\App\Config\ScopeConfigInterface$scopeConfig
string$exceptionConfigPath
string$scopeType
Json | null$serializer

Definition at line 50 of file DesignExceptions.php.

55  {
56  $this->scopeConfig = $scopeConfig;
57  $this->exceptionConfigPath = $exceptionConfigPath;
58  $this->scopeType = $scopeType;
59  $this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class);
60  }

Member Function Documentation

◆ getThemeByRequest()

getThemeByRequest ( \Magento\Framework\App\Request\Http  $request)

Get theme that should be applied for current user-agent according to design exceptions configuration

Parameters
\Magento\Framework\App\Request\Http$request
Returns
string|bool

Definition at line 68 of file DesignExceptions.php.

69  {
70  $userAgent = $request->getServer('HTTP_USER_AGENT');
71  if (empty($userAgent)) {
72  return false;
73  }
74  $expressions = $this->scopeConfig->getValue(
75  $this->exceptionConfigPath,
76  $this->scopeType
77  );
78  if (!$expressions) {
79  return false;
80  }
81  $expressions = $this->serializer->unserialize($expressions);
82  foreach ($expressions as $rule) {
83  if (preg_match($rule['regexp'], $userAgent)) {
84  return $rule['value'];
85  }
86  }
87  return false;
88  }
$expressions
Definition: side-menu.phtml:10

Field Documentation

◆ $exceptionConfigPath

$exceptionConfigPath
protected

Definition at line 28 of file DesignExceptions.php.

◆ $scopeConfig

$scopeConfig
protected

Definition at line 21 of file DesignExceptions.php.

◆ $scopeType

$scopeType
protected

Definition at line 35 of file DesignExceptions.php.


The documentation for this class was generated from the following file: