Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "path.alias_storage". in Drupal\Component\DependencyInjection\Container->get() (line 156 of /var/www/pickmeapp/web/core/lib/Drupal/Component/DependencyInjection/Container.php).

Comments

parashutiki created an issue. See original summary.

hunde.keba’s picture

Assigned: Unassigned » hunde.keba
andrii_svirin’s picture

I am not sure (espec with delte method), but these changes can work.

diff --git a/web/modules/contrib/flexible_google_cse/flexible_google_cse.install b/web/modules/contrib/flexible_google_cse/flexible_google_cse.install
--- a/web/modules/contrib/flexible_google_cse/flexible_google_cse.install	
+++ b/web/modules/contrib/flexible_google_cse/flexible_google_cse.install	
@@ -8,6 +8,9 @@
 /**
  * Implements hook_uninstall().
  */
-function flexible_google_cse_uninstall() {
-  \Drupal::service('path.alias_storage')->delete("/fgs-search");
+function flexible_google_cse_uninstall()
+{
+  \Drupal::entityTypeManager()->getStorage('path_alias')->delete([
+    'path' => '/fgs-search',
+  ]);
 }
diff --git a/web/modules/contrib/flexible_google_cse/src/Form/SearchConfig.php b/web/modules/contrib/flexible_google_cse/src/Form/SearchConfig.php
--- a/web/modules/contrib/flexible_google_cse/src/Form/SearchConfig.php	
+++ b/web/modules/contrib/flexible_google_cse/src/Form/SearchConfig.php	

@@ -208,9 +214,16 @@
   /**
    * A function to create A valid URL alias for the search result page.
    */
-  public function createAlias($search_url) {
-    $path = \Drupal::service('path.alias_storage')
-      ->save("/fgs-search", $search_url, "en");
+  public function createAlias($search_url)
+  {
+    $path_alias = \Drupal::entityTypeManager()->getStorage('path_alias')->create([
+      'path' => '/fgs-search',
+      'alias' => $search_url,
+      'langcode' => "en",
+    ]);
+    $path_alias->save();
+    $path = \Drupal::entityTypeManager()->getStorage('path_alias')->save($path_alias);
+
     return $path;
   }