public function ShurlyEditForm::access in ShURLy 8
Access check for editing a short url.
Parameters
\Drupal\Core\Session\AccountInterface $account:
$rid:
1 string reference to 'ShurlyEditForm::access'
File
- src/Form/ ShurlyEditForm.php, line 24 
Class
- ShurlyEditForm
- ShurlyActionsForm.
Namespace
Drupal\shurly\FormCode
public function access(AccountInterface $account, $rid) {
  if (is_numeric($rid)) {
    $row = \Drupal::database()
      ->query('SELECT uid, source, destination FROM {shurly} WHERE rid = :rid', [
      'rid' => $rid,
    ])
      ->fetchObject();
    // If there's a row, and either the user is an admin, or they've got permission to create and they own this URL, then let them access.
    return AccessResult::allowedIf($account
      ->hasPermission('administer short URLs') || $account
      ->hasPermission('edit own URLs') && $row->uid == $account
      ->id());
  }
}