/**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $config = $this->config('disqus.settings');
     $config->set('disqus_domain', $form_state->getValue('disqus_domain'))->set('behavior.disqus_localization', $form_state->getValue('disqus_localization'))->set('behavior.disqus_inherit_login', $form_state->getValue('disqus_inherit_login'))->set('behavior.disqus_disable_mobile', $form_state->getValue('disqus_disable_mobile'))->set('behavior.disqus_track_newcomment_ga', $form_state->getValue('disqus_track_newcomment_ga'))->set('advanced.disqus_useraccesstoken', $form_state->getValue('disqus_useraccesstoken'))->set('advanced.disqus_publickey', $form_state->getValue('disqus_publickey'))->set('advanced.disqus_secretkey', $form_state->getValue('disqus_secretkey'))->set('advanced.sso.disqus_sso', $form_state->getValue('disqus_sso'))->set('advanced.sso.disqus_use_site_logo', $form_state->getValue('disqus_use_site_logo'))->save();
     if ($form_state->hasValue('disqus_api_update')) {
         $config->set('advanced.api.disqus_api_update', $form_state->getValue('disqus_api_update'))->save();
     }
     if ($form_state->hasValue('disqus_api_delete')) {
         $config->set('advanced.api.disqus_api_delete', $form_state->getValue('disqus_api_delete'))->save();
     }
     $old_logo = $config->get('advanced.sso.disqus_logo');
     $new_logo = !$form_state->isValueEmpty('disqus_logo') ? $form_state->getValue(array('disqus_logo', 0)) : '';
     // Ignore if the file hasn't changed.
     if ($new_logo != $old_logo) {
         // Remove the old file and usage if previously set.
         if (!empty($old_logo)) {
             $file = $this->entityTypeManager->getStorage('file')->load($old_logo);
             $this->fileUsage->delete($file, 'disqus', 'disqus');
         }
         // Update the new file and usage.
         if (!empty($new_logo)) {
             $file = $this->entityTypeManager->getStorage('file')->load($new_logo);
             $this->fileUsage->add($file, 'disqus', 'disqus', 1);
         }
     }
     $config->set('advanced.sso.disqus_logo', $new_logo)->save();
     parent::submitForm($form, $form_state);
 }
Example #2
0
 /**
  * Deletes a file.
  *
  * @param int $file_id
  *   The file id.
  * @param int $feed_id
  *   The feed id.
  *
  * @see file_delete()
  */
 protected function deleteFile($file_id, $feed_id)
 {
     if ($file = $this->fileStorage->load($file_id)) {
         $this->fileUsage->delete($file, 'feeds', $this->pluginType(), $feed_id);
     }
 }