Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions
LayoutUpdateConverter Class Reference
Inheritance diagram for LayoutUpdateConverter:
SerializedToJson DataConverterInterface

Public Member Functions

 __construct (Serialize $serialize, Json $json, Normalizer $normalizer)
 
 convert ($value)
 
- Public Member Functions inherited from SerializedToJson
 __construct (Serialize $serialize, Json $json)
 
 convert ($value)
 

Protected Member Functions

 isValidJsonValue ($value)
 
 unserializeValue ($value)
 
 encodeJson ($value)
 
- Protected Member Functions inherited from SerializedToJson
 isValidJsonValue ($value)
 
 unserializeValue ($value)
 
 encodeJson ($value)
 

Detailed Description

Convert conditions_encoded part of layout update data from serialized to JSON format

Definition at line 17 of file LayoutUpdateConverter.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Serialize  $serialize,
Json  $json,
Normalizer  $normalizer 
)

Constructor

Parameters
Serialize$serialize
Json$json
Normalizer$normalizer

Definition at line 31 of file LayoutUpdateConverter.php.

35  {
36  $this->normalizer = $normalizer;
37  parent::__construct($serialize, $json);
38  }

Member Function Documentation

◆ convert()

convert (   $value)

Convert conditions_encoded part of layout update data from serialized to JSON format

Parameters
string$value
Returns
string
Exceptions
DataConversionException

Implements DataConverterInterface.

Definition at line 47 of file LayoutUpdateConverter.php.

48  {
49  preg_match_all(
50  '/^(.*?conditions_encoded<\/argument><argument [^<]*>)(.*?)(<\/argument>.*?)$/si',
51  $value,
52  $matches,
53  PREG_SET_ORDER
54  );
55  if (isset($matches[0])) {
56  $matchSegments = $matches[0];
57  $matchSegments[2] = parent::convert($matchSegments[2]);
58  return $matchSegments[1] . $matchSegments[2] . $matchSegments[3];
59  } else {
60  return $value;
61  }
62  }
$value
Definition: gender.phtml:16

◆ encodeJson()

encodeJson (   $value)
protected

Definition at line 86 of file LayoutUpdateConverter.php.

87  {
88  return htmlspecialchars(
89  $this->normalizer->replaceReservedCharacters(parent::encodeJson($value))
90  );
91  }
$value
Definition: gender.phtml:16

◆ isValidJsonValue()

isValidJsonValue (   $value)
protected

Definition at line 67 of file LayoutUpdateConverter.php.

68  {
69  $value = $this->normalizer->restoreReservedCharacters($value);
70  return parent::isValidJsonValue($value);
71  }
$value
Definition: gender.phtml:16

◆ unserializeValue()

unserializeValue (   $value)
protected

Definition at line 76 of file LayoutUpdateConverter.php.

77  {
78  $value = htmlspecialchars_decode($value);
79  $value = $this->restoreReservedCharactersInSerializedContent($value);
80  return parent::unserializeValue($value);
81  }
$value
Definition: gender.phtml:16

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