public function Instances::removeInstance in Smart Date 3.x
Same name and namespace in other branches
- 8.2 modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeInstance()
- 3.0.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeInstance()
- 3.1.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeInstance()
- 3.2.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeInstance()
- 3.3.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeInstance()
- 3.4.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeInstance()
Removing a rule instance.
Parameters
int $index: Index of the instance to remove.
int|null $oid: SmartDateOverride override id if existing.
Throws
\Drupal\Core\Entity\EntityStorageException
File
- modules/
smart_date_recur/ src/ Controller/ Instances.php, line 432
Class
- Instances
- Provides listings of instances (with overrides) for a specified rule.
Namespace
Drupal\smart_date_recur\ControllerCode
public function removeInstance(int $index, ?int $oid) {
$rrule = $this->rrule
->id();
// Delete existing override, if it exists.
if ($oid) {
$existing = SmartDateOverride::load($oid);
$existing
->delete();
}
$override = SmartDateOverride::create([
'rrule' => $rrule,
'rrule_index' => $index,
]);
$override
->save();
}