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

Public Member Functions

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

Protected Member Functions

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

Detailed Description

Convert conditions_encoded part of cms block content data from serialized to JSON format

Definition at line 18 of file ContentConverter.php.

Constructor & Destructor Documentation

◆ __construct()

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

ContentConverter constructor

Parameters
Serialize$serialize
Json$json
ParameterFactory$parameterFactory
Normalizer$normalizer

Definition at line 38 of file ContentConverter.php.

43  {
44  $this->parameterFactory = $parameterFactory;
45  $this->normalizer = $normalizer;
46  parent::__construct($serialize, $json);
47  }

Member Function Documentation

◆ convert()

convert (   $value)

Convert conditions_encoded part of block content from serialized to JSON format

Parameters
string$value
Returns
string
Exceptions
DataConversionException

Implements DataConverterInterface.

Definition at line 56 of file ContentConverter.php.

57  {
58  preg_match_all('/(.*?){{widget(.*?)}}/si', $value, $matches, PREG_SET_ORDER);
59  if (empty($matches)) {
60  return $value;
61  }
62  $convertedValue = '';
63  foreach ($matches as $match) {
64  $convertedValue .= $match[1] . '{{widget' . $this->convertWidgetParams($match[2]) . '}}';
65  }
66  preg_match_all('/(.*?{{widget.*?}})*(?<ending>.*?)$/si', $value, $matchesTwo, PREG_SET_ORDER);
67  if (isset($matchesTwo[0])) {
68  $convertedValue .= $matchesTwo[0]['ending'];
69  }
70 
71  return $convertedValue;
72  }
$value
Definition: gender.phtml:16

◆ isValidJsonValue()

isValidJsonValue (   $value)
protected

Definition at line 77 of file ContentConverter.php.

78  {
79  return parent::isValidJsonValue($this->normalizer->restoreReservedCharacters($value));
80  }
$value
Definition: gender.phtml:16

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