piyuesh23/cors

Fatal Error in the Form class

Opened this issue · 1 comments

This looks promising. Since Rest Services are being implemented in Drupal CORE, I would think that the Drupal Core team would want to implement CORS into D8 core as well, since it will be needed. Have you talked with the guys who have been implementing REST? That is not complete yet, but it is being worked on.

I tried installing on the current Drupal 8 Beta 10.

First thing I noticed is that the service didn't show up on the Services page:

          ../admin/config/services

And hence also not at "services/cors".

Then I ran clear caches and got a fatal error message that looks like it may be the result of the module not fully implementing the latest interface?

"Fatal error: Class Drupal\cors\Form\CorsConfigForm contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Drupal\Core\Form\ConfigFormBase::getEditableConfigNames) in C:\ . . . \My Web Sites\drupal-8.0.10\modules\cors\src\Form\CorsConfigForm.php on line 68"

We shouldn't be surprised. D8 is still a "moving target", after all.

Here's a patch to add getEditableConfigNames() This fixes the installation issue that I had. If I have any further issues, I will note them. Hmmm . . . there's no way to attach a patch here?


diff --git a/src/Form/CorsConfigForm.php b/src/Form/CorsConfigForm.php
index e41996c..ea78b6e 100644
--- a/src/Form/CorsConfigForm.php
+++ b/src/Form/CorsConfigForm.php
@@ -60,9 +60,14 @@ class CorsConfigForm extends ConfigFormBase {
}
}

  • $config = $this->configFactory->get('cors.config');
  • $config = \Drupal::configFactory()->getEditable('cors.config');
    $config->set('cors_domains', $settings);
    $config->save();
    drupal_set_message(t('Configuration saved successfully!'), 'status', FALSE);
    }
  • protected function getEditableConfigNames() {
  • return ['cors.config'];
  • }
  • }