Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ColorPicker.php
Go to the documentation of this file.
1 <?php
7 declare(strict_types=1);
8 
10 
15 
22 {
23  const NAME = 'colorPicker';
24 
25  const DEFAULT_MODE = 'full';
26 
32  private $modesProvider;
33 
43  public function __construct(
45  ColorModesProvider $modesProvider,
46  array $components = [],
47  array $data = []
48  ) {
49  $this->modesProvider = $modesProvider;
50  parent::__construct($context, $components, $data);
51  }
52 
58  public function getComponentName(): string
59  {
60  return static::NAME;
61  }
62 
68  public function prepare() : void
69  {
70  $modes = $this->modesProvider->getModes();
71  $colorPickerModeSetting = $this->getData('config/colorPickerMode');
72  $colorFormatSetting = $this->getData('config/colorFormat');
73  $colorPickerMode = $modes[$colorPickerModeSetting] ?? $modes[self::DEFAULT_MODE];
74  $colorPickerMode['preferredFormat'] = $colorFormatSetting;
75  $this->_data['config']['colorPickerConfig'] = $colorPickerMode;
76 
77  parent::prepare();
78  }
79 }
__construct(ContextInterface $context, ColorModesProvider $modesProvider, array $components=[], array $data=[])
Definition: ColorPicker.php:43