Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / linkchecker / src / Form / LinkCheckerEditLinkSettingsForm.php
index d020b0631d9b0aae39c8f9202ecd8a2bad7723bd..33170bf66d7d8d1bc10bcdd84bd2c10ca718fefa 100644 (file)
@@ -20,7 +20,12 @@ class LinkCheckerEditLinkSettingsForm {
     $form['settings'] = [
       '#type' => 'details',
       '#title' => $this->t('Settings'),
-      '#description' => $this->t('The link <a href=":url">:url</a> was last checked on @last_checked and failed @fail_count times.', [':url' => $link->url, '@fail_count' => $link->fail_count, '@last_checked' => DateFormatter::format($link->last_checked)]),
+      '#description' => $this->t('The link <a href=":url">:url</a> was last checked on @last_checked and failed @fail_count times.',
+        [
+          ':url' => $link->url,
+          '@fail_count' => $link->fail_count,
+          '@last_checked' => DateFormatter::format($link->last_checked),
+        ]),
       '#open' => TRUE,
     ];
 
@@ -67,51 +72,54 @@ class LinkCheckerEditLinkSettingsForm {
   public function submitForm(array &$form, FormStateInterface $form_state) {
     // Force link re-check asap.
     if ($form_state->getValue('recheck')) {
-      db_update('linkchecker_link')
+      \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $form_state->getValue('lid'))
-        ->fields(array('last_checked' => 0))
+        ->fields(['last_checked' => 0])
         ->execute();
       drupal_set_message(t('The link %url will be checked again on the next cron run.', ['%url' => $form_state->getValue('url')]));
     }
 
     if ($form_state->getValue('method') != $form['settings']['method']['#default_value']) {
       // Update settings and reset statistics for a quick re-check.
-      db_update('linkchecker_link')
+      \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $form_state->getValue('lid'))
-        ->fields(array(
+        ->fields([
           'method' => $form_state->getValue('method'),
           'fail_count' => 0,
           'last_checked' => 0,
           'status' => $form_state->getValue('status'),
-        ))
+        ])
         ->execute();
-      drupal_set_message(t('The link settings for %url have been saved and the fail counter has been reset.', array('%url' => $form_state->getValue('url'))));
+      drupal_set_message(t('The link settings for %url have been saved and the fail counter has been reset.', ['%url' => $form_state->getValue('url')]));
     }
     else {
       // Update setting only.
-      db_update('linkchecker_link')
+      \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $form_state->getValue('lid'))
-        ->fields(array(
+        ->fields([
           'method' => $form_state->getValue('method'),
           'status' => $form_state->getValue('status'),
-        ))
+        ])
         ->execute();
-      drupal_set_message(t('The link settings for %url have been saved.', array('%url' => $form_state->getValue('url'))));
+      drupal_set_message(t('The link settings for %url have been saved.', ['%url' => $form_state->getValue('url')]));
     }
   }
 
   /**
    * Checks access for a specific request.
    *
-   * @param \Drupal\Core\Session\AccountInterface $account
+   * @param $link
+   *
+   * @return
    *   Run access checks for this account.
+   *
+   * @FIXME
    */
-  // @FIXME
   public function access($link) {
     // Check permissions and combine that with any custom access checking needed. Pass forward
     // parameters from the route and/or request as needed.
+    $account = \Drupal::currentUser();
     return AccessResult::allowedIf($account->hasPermission('edit link settings') && _linkchecker_link_access($link));
-        //$this->someOtherCustomCondition());
   }
 
 }