You are here

public static function DateRecurPartGrid::configSettingsToGrid in Recurring Dates Field 8.2

Same name and namespace in other branches
  1. 3.x src/DateRecurPartGrid.php \Drupal\date_recur\DateRecurPartGrid::configSettingsToGrid()
  2. 3.0.x src/DateRecurPartGrid.php \Drupal\date_recur\DateRecurPartGrid::configSettingsToGrid()
  3. 3.1.x src/DateRecurPartGrid.php \Drupal\date_recur\DateRecurPartGrid::configSettingsToGrid()

Converts settings from date recur field configuration to a part grid.

Parameters

array $parts: Part configuration.

Return value

\Drupal\date_recur\DateRecurPartGrid A new parts grid.

5 calls to DateRecurPartGrid::configSettingsToGrid()
DateRecurFieldItemList::getPartGrid in src/Plugin/Field/FieldType/DateRecurFieldItemList.php
Get the parts grid for this field.
DateRecurPartGridUnitTest::testSettingsToGridAllFrequenciesDisabled in tests/src/Unit/DateRecurPartGridUnitTest.php
Tests config settings to grid helper.
DateRecurPartGridUnitTest::testSettingsToGridAllowEverything in tests/src/Unit/DateRecurPartGridUnitTest.php
Tests config settings to grid helper.
DateRecurPartGridUnitTest::testSettingsToGridAllPartsForFrequencyAllowed in tests/src/Unit/DateRecurPartGridUnitTest.php
Tests config settings to grid helper.
DateRecurPartGridUnitTest::testSettingsToGridOriginal in tests/src/Unit/DateRecurPartGridUnitTest.php
Tests config settings to grid helper.

File

src/DateRecurPartGrid.php, line 99

Class

DateRecurPartGrid
Frequency/part support grid.

Namespace

Drupal\date_recur

Code

public static function configSettingsToGrid(array $parts) {
  $grid = new static();
  if (!empty($parts['all'])) {
    return $grid;
  }
  $frequencies = $parts['frequencies'] ?? [];
  foreach ($frequencies as $frequency => $frequencyParts) {
    $grid
      ->allowParts($frequency, $frequencyParts);
  }
  return $grid;
}