/**
  * The content callback for the Blacklist list of current entries.
  *
  * @param string $type
  *   A particular list type to show (based on the entry 'reason').
  */
 function content($type = NULL)
 {
     MollomUtilities::getAdminAPIKeyStatus();
     MollomUtilities::displayMollomTestModeWarning();
     $items = BlacklistStorage::getList($type);
     $rows = array();
     // Edit/delete.
     $header = array();
     if (empty($type)) {
         $header['type'] = $this->t('List');
     }
     $header['context'] = $this->t('Context');
     $header['matches'] = $this->t('Matches');
     $header['value'] = $this->t('Value');
     $header['operations'] = $this->t('Operations');
     foreach ($items as $entry) {
         $data = array($entry['context'], $entry['match'], $entry['value'], array('data' => array('#type' => 'operations', '#links' => array(array('title' => $this->t('Delete'), 'url' => Url::fromRoute('mollom.blacklist.delete', array('entry_id' => $entry['id'])))))));
         if (empty($type)) {
             array_unshift($data, $entry['reason']);
         }
         $rows[] = $data;
     }
     $build['table'] = array('#type' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => $this->t('There are no entries in the blacklist.'), '#attributes' => array('id' => 'mollom-blacklist-list'));
     return $build;
 }
 /**
  * Form submission handler.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Delete the entry.
     BlacklistStorage::deleteEntry($this->entry['id']);
     // Set a message that the entry was deleted.
     drupal_set_message(t('The blacklist entry %term was deleted from the @type blacklist.', array('%term' => $this->entry['value'], '@type' => $this->entry['reason'])));
     // Redirect the user to the list controller when complete.
     $form_state->setRedirect('mollom.blacklist.list');
 }
 /**
  * Loads a blacklist entry by id and saves it to the class variable.
  *
  * @param $entry_id
  *   The id of the blacklist entry
  * @return array
  *   The blacklist entry data (or data for a blank entry)
  */
 private function loadByEntryId($entry_id = NULL)
 {
     if (is_null($entry_id)) {
         return array();
     }
     $this->setEntry(BlacklistStorage::getEntry($entry_id));
     return $this->getEntry();
 }