public function DateRecurPartGrid::isPartAllowed in Recurring Dates Field 3.0.x
Same name and namespace in other branches
- 8.2 src/DateRecurPartGrid.php \Drupal\date_recur\DateRecurPartGrid::isPartAllowed()
- 3.x src/DateRecurPartGrid.php \Drupal\date_recur\DateRecurPartGrid::isPartAllowed()
- 3.1.x src/DateRecurPartGrid.php \Drupal\date_recur\DateRecurPartGrid::isPartAllowed()
Determines whether a part is allowed.
Parameters
string $frequency: A frequency.
string $part: A part.
Return value
bool Whether a part is supported.
Throws
\Drupal\date_recur\Exception\DateRecurRulePartIncompatible Part is incompatible with frequency.
File
- src/
DateRecurPartGrid.php, line 75
Class
- DateRecurPartGrid
- Frequency/part support grid.
Namespace
Drupal\date_recurCode
public function isPartAllowed(string $frequency, string $part) : bool {
assert(in_array($frequency, DateRecurRruleMap::FREQUENCIES, TRUE) && in_array($part, DateRecurRruleMap::PARTS, TRUE));
if (in_array($part, DateRecurRruleMap::INCOMPATIBLE_PARTS[$frequency], TRUE)) {
throw new DateRecurRulePartIncompatible();
}
if ($this
->isAllowEverything()) {
return TRUE;
}
$partsInFrequency = $this->allowedParts[$frequency] ?? [];
// Supports the part, or everything in this frequency.
return in_array($part, $partsInFrequency, TRUE) || in_array(DateRecurItem::PART_SUPPORTS_ALL, $partsInFrequency, TRUE);
}