protected function DomApplyStyles::setStyles in Migrate Plus 8.5
Retrieve the list of styles based on configuration.
The styles configuration is a string: styles are separated by "\r\n", and each one has the format 'element(\.class)*|label'. Convert this to an array with 'label' => 'element.class', and save as $this->styles.
Parameters
string $format: The text format from which to get configured styles.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
1 call to DomApplyStyles::setStyles()
- DomApplyStyles::__construct in src/
Plugin/ migrate/ process/ DomApplyStyles.php - Constructs a \Drupal\Component\Plugin\PluginBase object.
File
- src/
Plugin/ migrate/ process/ DomApplyStyles.php, line 129
Class
- DomApplyStyles
- Apply Editor styles to configured elements.
Namespace
Drupal\migrate_plus\Plugin\migrate\processCode
protected function setStyles($format) {
if (empty($format) || !is_string($format)) {
$message = 'The "format" option must be a non-empty string.';
throw new InvalidPluginDefinitionException($this
->getPluginId(), $message);
}
$editor_styles = $this->configFactory
->get("editor.editor.{$format}")
->get('settings.plugins.stylescombo.styles');
foreach (explode("\r\n", $editor_styles) as $rule) {
if (preg_match('/(.*)\\|(.*)/', $rule, $matches)) {
$this->styles[$matches[2]] = $matches[1];
}
}
}