public function ContentModerationNotificationsFormBase::exists in Content Moderation Notifications 8
Same name and namespace in other branches
- 8.3 src/Form/ContentModerationNotificationsFormBase.php \Drupal\content_moderation_notifications\Form\ContentModerationNotificationsFormBase::exists()
- 8.2 src/Form/ContentModerationNotificationsFormBase.php \Drupal\content_moderation_notifications\Form\ContentModerationNotificationsFormBase::exists()
Checks for an existing content_moderation_notification.
Parameters
string|int $entity_id: The entity ID.
array $element: The form element.
FormStateInterface $form_state: The form state.
Return value
bool TRUE if this format already exists, FALSE otherwise.
File
- src/
Form/ ContentModerationNotificationsFormBase.php, line 209
Class
- ContentModerationNotificationsFormBase
- Class ContentModerationNotificationFormBase.
Namespace
Drupal\content_moderation_notifications\FormCode
public function exists($entity_id, array $element, FormStateInterface $form_state) {
// Use the query factory to build a new content_moderation_notification entity query.
$query = $this->entityQueryFactory
->get('content_moderation_notification');
// Query the entity ID to see if its in use.
$result = $query
->condition('id', $element['#field_prefix'] . $entity_id)
->execute();
// We don't need to return the ID, only if it exists or not.
return (bool) $result;
}