class YamlFormAccess in YAML Form 8
Defines the custom access control handler for the form entities.
Hierarchy
- class \Drupal\yamlform\Access\YamlFormAccess
Expanded class hierarchy of YamlFormAccess
File
- src/
Access/ YamlFormAccess.php, line 14
Namespace
Drupal\yamlform\AccessView source
class YamlFormAccess {
/**
* Check whether the user has 'administer yamlform' or 'administer yamlform submission' permission.
*
* @param \Drupal\Core\Session\AccountInterface $account
* Run access checks for this account.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public static function checkAdminAccess(AccountInterface $account) {
return AccessResult::allowedIf($account
->hasPermission('administer yamlform') || $account
->hasPermission('administer yamlform submission'));
}
/**
* Check whether the user can view submissions.
*
* @param \Drupal\Core\Session\AccountInterface $account
* Run access checks for this account.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public static function checkSubmissionAccess(AccountInterface $account) {
return AccessResult::allowedIf($account
->hasPermission('administer yamlform') || $account
->hasPermission('administer yamlform submission') || $account
->hasPermission('view any yamlform submission'));
}
/**
* Check whether the user has 'administer' or 'overview' permission.
*
* @param \Drupal\Core\Session\AccountInterface $account
* Run access checks for this account.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public static function checkOverviewAccess(AccountInterface $account) {
return AccessResult::allowedIf($account
->hasPermission('administer yamlform') || $account
->hasPermission('administer yamlform submission') || $account
->hasPermission('access yamlform overview'));
}
/**
* Check that form submission has email and the user can update any form submission.
*
* @param \Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission
* A form submission.
* @param \Drupal\Core\Session\AccountInterface $account
* Run access checks for this account.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public static function checkEmailAccess(YamlFormSubmissionInterface $yamlform_submission, AccountInterface $account) {
$yamlform = $yamlform_submission
->getYamlForm();
if ($yamlform
->access('submission_update_any')) {
$handlers = $yamlform
->getHandlers();
foreach ($handlers as $handler) {
if ($handler instanceof YamlFormHandlerMessageInterface) {
return AccessResult::allowed();
}
}
}
return AccessResult::forbidden();
}
/**
* Check whether the user can access an entity's form results.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* An entity.
* @param \Drupal\Core\Session\AccountInterface $account
* Run access checks for this account.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public static function checkEntityResultsAccess(EntityInterface $entity, AccountInterface $account) {
return AccessResult::allowedIf($entity
->access('update') && $entity
->hasField('yamlform') && $entity->yamlform->entity);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
YamlFormAccess:: |
public static | function | Check whether the user has 'administer yamlform' or 'administer yamlform submission' permission. | |
YamlFormAccess:: |
public static | function | Check that form submission has email and the user can update any form submission. | |
YamlFormAccess:: |
public static | function | Check whether the user can access an entity's form results. | |
YamlFormAccess:: |
public static | function | Check whether the user has 'administer' or 'overview' permission. | |
YamlFormAccess:: |
public static | function | Check whether the user can view submissions. |