Skip to content
Snippets Groups Projects
Commit 648e3622 authored by catch's avatar catch
Browse files

Issue #2132551 by Gábor Hojtsy, alexpott, kfritsche: Picture module uses config keys with a dot.

parent afa7d30c
No related branches found
No related tags found
No related merge requests found
......@@ -18,10 +18,16 @@ picture.mappings.*:
label: 'Mappings'
sequence:
- type: sequence
label: 'Mapping'
label: 'Source type'
sequence:
- type: string
label: 'Image style'
- type: sequence
label: 'Source'
sequence:
- type: sequence
label: 'Machine name'
sequence:
- type: string
label: 'Image style'
breakpointGroup:
type: string
label: 'Breakpoint group'
......
......@@ -95,6 +95,16 @@ public function save() {
if (isset($this->breakpointGroup) && is_object($this->breakpointGroup)) {
$this->breakpointGroup = $this->breakpointGroup->id();
}
// Split the breakpoint ids into their different parts, as dots as
// identifiers are not possible.
$loaded_mappings = $this->mappings;
$this->mappings = array();
foreach ($loaded_mappings as $breakpoint_id => $mapping) {
list($source_type, $source, $name) = explode('.', $breakpoint_id);
$this->mappings[$source_type][$source][$name] = $mapping;
}
parent::save();
$this->loadBreakpointGroup();
$this->loadAllMappings();
......@@ -129,10 +139,14 @@ protected function loadAllMappings() {
$this->mappings = array();
if ($this->breakpointGroup) {
foreach ($this->breakpointGroup->getBreakpoints() as $breakpoint_id => $breakpoint) {
// Get the components of the breakpoint ID to match the format of the
// configuration file.
list($source_type, $source, $name) = explode('.', $breakpoint_id);
// Get the mapping for the default multiplier.
$this->mappings[$breakpoint_id]['1x'] = '';
if (isset($loaded_mappings[$breakpoint_id]['1x'])) {
$this->mappings[$breakpoint_id]['1x'] = $loaded_mappings[$breakpoint_id]['1x'];
if (isset($loaded_mappings[$source_type][$source][$name]['1x'])) {
$this->mappings[$breakpoint_id]['1x'] = $loaded_mappings[$source_type][$source][$name]['1x'];
}
// Get the mapping for the other multipliers.
......@@ -140,8 +154,8 @@ protected function loadAllMappings() {
foreach ($breakpoint->multipliers as $multiplier => $status) {
if ($status) {
$this->mappings[$breakpoint_id][$multiplier] = '';
if (isset($loaded_mappings[$breakpoint_id][$multiplier])) {
$this->mappings[$breakpoint_id][$multiplier] = $loaded_mappings[$breakpoint_id][$multiplier];
if (isset($loaded_mappings[$source_type][$source][$name][$multiplier])) {
$this->mappings[$breakpoint_id][$multiplier] = $loaded_mappings[$source_type][$source][$name][$multiplier];
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment