diff --git a/forms_steps.module b/forms_steps.module
index 147d48d..59e1726 100644
--- a/forms_steps.module
+++ b/forms_steps.module
@@ -37,8 +37,10 @@ function forms_steps_help($route_name, RouteMatchInterface $route_match) {
  */
 function forms_steps_form_alter(&$form, FormStateInterface $form_state, $form_id) {
   $formStateStorage = $form_state->getStorage();
+  $currentRoute = \Drupal::routeMatch()->getRouteName();
   if (
-    preg_match('/^forms_steps\./', \Drupal::routeMatch()->getRouteName())
+    is_string($currentRoute)
+    && preg_match('/^forms_steps\./', $currentRoute)
     && isset($formStateStorage['form_steps'])
   ) {
     $form['actions']['submit']['#submit'][] = 'Drupal\forms_steps\Form\FormsStepsAlter::setNextRoute';
diff --git a/src/Service/WorkflowManager.php b/src/Service/WorkflowManager.php
index d673d88..3a15ec6 100644
--- a/src/Service/WorkflowManager.php
+++ b/src/Service/WorkflowManager.php
@@ -135,7 +135,8 @@ class WorkflowManager {
 
     $currentRoute = $this->currentRouteMatch->getRouteName();
     if (
-      preg_match('/^forms_steps\./', $currentRoute)
+      is_string($currentRoute)
+      && preg_match('/^forms_steps\./', $currentRoute)
       && strcmp($entity->getEntityTypeId(), Workflow::ENTITY_TYPE) != 0
     ) {
 
@@ -213,7 +214,8 @@ class WorkflowManager {
   public function entityInsert(EntityInterface $entity) {
     $currentRoute = $this->currentRouteMatch->getRouteName();
     if (
-      preg_match('/^forms_steps\./', $currentRoute)
+      is_string($currentRoute)
+      && preg_match('/^forms_steps\./', $currentRoute)
       && strcmp($entity->getEntityTypeId(), Workflow::ENTITY_TYPE) != 0
     ) {
 
