protected function YamlFormSubmissionForm::checkUserLimit in YAML Form 8
Check form submission user limit.
Return value
bool TRUE if form submission user limit have been met.
2 calls to YamlFormSubmissionForm::checkUserLimit()
- YamlFormSubmissionForm::getCustomForm in src/
YamlFormSubmissionForm.php - Get custom form which is displayed instead of the form's elements.
- YamlFormSubmissionForm::save in src/
YamlFormSubmissionForm.php - Form submission handler for the 'save' action.
File
- src/
YamlFormSubmissionForm.php, line 1315
Class
- YamlFormSubmissionForm
- Provides a form to collect and edit submissions.
Namespace
Drupal\yamlformCode
protected function checkUserLimit() {
$account = $this
->currentUser();
$yamlform = $this
->getYamlForm();
// Anonymous users can't have limits.
if ($account
->isAnonymous()) {
return FALSE;
}
// Check per entity user limit.
$entity_limit_user = $this
->getYamlFormSetting('entity_limit_user');
if ($entity_limit_user && ($source_entity = $this
->getLimitSourceEntity())) {
if ($this->storage
->getTotal($yamlform, $source_entity, $account) >= $entity_limit_user) {
return TRUE;
}
}
// Check user limit.
$limit_user = $this
->getYamlFormSetting('limit_user');
if ($limit_user && $this->storage
->getTotal($yamlform, NULL, $account) >= $limit_user) {
return TRUE;
}
return FALSE;
}