/** * @param TextLayerInterface $layer */ public function processBox(TextLayerInterface $layer) { if (!$layer->has('text.box.paddings')) { $layer->add(['text.box.paddings' => [0, 0, 0, 0], 'text.box.hex_color' => null]); return; } $paddings = array_values($layer->get('text.box.paddings')); $arr = []; for ($i = 0; $i < 4; $i++) { if (!isset($paddings[$i]) || 0 > $paddings[$i]) { $arr[$i] = 0; } else { $arr[$i] = (int) $paddings[$i]; } } $layer->set('text.box.paddings', $arr); if (null !== ($color = $layer->get('text.box.hex_color'))) { $color = $this->sanitizeHexColor($color); $layer->set('text.box.hex_color', $color['hex']); $layer->set('text.box.rgb_color', $color['rgb']); } else { $layer->set('text.box.rgb_color', null); } }