public function SmartDateRule::getParentEntity in Smart Date 3.x
Same name and namespace in other branches
- 8.2 modules/smart_date_recur/src/Entity/SmartDateRule.php \Drupal\smart_date_recur\Entity\SmartDateRule::getParentEntity()
- 3.0.x modules/smart_date_recur/src/Entity/SmartDateRule.php \Drupal\smart_date_recur\Entity\SmartDateRule::getParentEntity()
- 3.1.x modules/smart_date_recur/src/Entity/SmartDateRule.php \Drupal\smart_date_recur\Entity\SmartDateRule::getParentEntity()
- 3.2.x modules/smart_date_recur/src/Entity/SmartDateRule.php \Drupal\smart_date_recur\Entity\SmartDateRule::getParentEntity()
- 3.3.x modules/smart_date_recur/src/Entity/SmartDateRule.php \Drupal\smart_date_recur\Entity\SmartDateRule::getParentEntity()
- 3.4.x modules/smart_date_recur/src/Entity/SmartDateRule.php \Drupal\smart_date_recur\Entity\SmartDateRule::getParentEntity()
Retrieve the entity to which the rule is attached.
File
- modules/
smart_date_recur/ src/ Entity/ SmartDateRule.php, line 254
Class
- SmartDateRule
- Defines the Smart date rule entity.
Namespace
Drupal\smart_date_recur\EntityCode
public function getParentEntity($id_only = FALSE) {
// Retrieve the entity using the rule id.
$rid = $this
->id();
if (empty($rid)) {
return FALSE;
}
$entity_type = $this->entity_type
->getString();
$field_name = $this->field_name
->getString();
$result = \Drupal::entityQuery($entity_type)
->condition($field_name . '.rrule', $rid)
->execute();
$id = array_pop($result);
if ($id_only) {
return $id;
}
$entity_manager = \Drupal::entityTypeManager($entity_type);
$entity_storage = $entity_manager
->getStorage($entity_type);
$entity = $entity_storage
->load($id);
return $entity;
}