You are here

public function ProvidersController::saveProviderSettings in Persistent URL 8

1 string reference to 'ProvidersController::saveProviderSettings'
purl.routing.yml in ./purl.routing.yml
purl.routing.yml

File

src/Controller/ProvidersController.php, line 39

Class

ProvidersController

Namespace

Drupal\purl\Controller

Code

public function saveProviderSettings(Request $request) {
  if ($request
    ->getMethod() === "POST") {
    $providers = $request->request
      ->get('providers', array());
    foreach ($providers as $providerId => $data) {
      $provider = $this->providerManager
        ->getProvider($providerId);
      if ($data['method']) {
        $this->providerManager
          ->saveProviderConfiguration($providerId, $data['method'], isset($data['settings']) ? $data['settings'] : array());
        $this->modifierIndex
          ->indexModifiers($provider, $data['method']);
      }
      else {
        $this->providerManager
          ->deleteProviderConfiguration($providerId);
        $this->modifierIndex
          ->deleteEntriesByProvider($providerId);
      }
    }
  }
  return $this
    ->redirect('purl.admin');
}