Task/Generate/ComponentCollector.php
protected function collectPresetValue(
    &$collected_data,
    $multiple_presets,
    $target_property_name,
    $target_property_info,
    $preset_property_data
  ) {
    // Check the format of the value is compatible with multiple presets.
    if ($multiple_presets) {
      if (!in_array($target_property_info['format'], ['array', 'compound'])) {
        // TODO: check cardinality is allowable as well!
        // TODO: give the preset name! ARGH another parameter :(
        throw new \Exception("Multiple presets not compatible with single-valued properties, with target property {$target_property_name}.");
      }
    }

    if (isset($collected_data[$target_property_name])) {
      // Merge the data. The check above should have covered that this is
      // allowed.
      $collected_data[$target_property_name] = array_merge($collected_data[$target_property_name], $preset_property_data);
    }
    else {
      $collected_data[$target_property_name] = $preset_property_data;
    }
  }
protected function collectPresetValue(
    &$collected_data,
    $multiple_presets,
    $target_property_name,
    $target_property_info,
    $preset_property_data
  ) {
    // Check the format of the value is compatible with multiple presets.
    if ($multiple_presets) {
      if (!in_array($target_property_info['format'], ['array', 'compound'])) {
        // TODO: check cardinality is allowable as well!
        // TODO: give the preset name! ARGH another parameter :(
        throw new \Exception("Multiple presets not compatible with single-valued properties, with target property {$target_property_name}.");
      }
    }

    if (isset($collected_data[$target_property_name])) {
      // Merge the data. The check above should have covered that this is
      // allowed.
      $collected_data[$target_property_name] = array_merge($collected_data[$target_property_name], $preset_property_data);
    }
    else {
      $collected_data[$target_property_name] = $preset_property_data;
    }
  }
protected function collectPresetValue ( & $ collected_data , $ multiple_presets , $ target_property_name , $ target_property_info , $ preset_property_data ) { // Check the format of the value is compatible with multiple presets. if ( $ multiple_presets ) { if ( ! in_array ( $ target_property_info [ 'format' ] , [ 'array' , 'compound' ] ) ) { // TODO: check cardinality is allowable as well! // TODO: give the preset name! ARGH another parameter :( throw new \ Exception ( "Multiple presets not compatible with single-valued properties, with target property {$target_property_name}." ) ; } } if ( isset ( $ collected_data [ $ target_property_name ] ) ) { // Merge the data. The check above should have covered that this is // allowed. $ collected_data [ $ target_property_name ] = array_merge ( $ collected_data [ $ target_property_name ] , $ preset_property_data ) ; } else { $ collected_data [ $ target_property_name ] = $ preset_property_data ; } }
Collect values for presets.

Helper for setPresetValues(). Merges values from multiple presets so that
they can be set into the actual component data in one go.

@param array &$collected_data
The data collected from presets so far. Further data for this call should
be added to this.
@param bool $multiple_presets
Whether the current preset property is multi-valued or not.
@param string $target_property_name
The name of the property to set from the preset.
@param array $target_property_info
The property info array of the target property.
@param mixed $preset_property_data
The value from the preset for the target property.
Collect values for presets .