From d9ef155aab7d3acbe4430a3973e69b9493b97335 Mon Sep 17 00:00:00 2001
From: Danny Englander <dannyenglander311@gmail.com>
Date: Fri, 21 Feb 2020 12:57:54 -0800
Subject: [PATCH] adding updated code for patch

---
 page_specific_class.module                 | 7 +++++--
 src/Form/PageSpecificClassSettingsForm.php | 4 +++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/page_specific_class.module b/page_specific_class.module
index e1c8a47..1730d07 100644
--- a/page_specific_class.module
+++ b/page_specific_class.module
@@ -4,7 +4,7 @@
  * @file
  *
  * This file adds a class to the body tag page-wise.
- * 
+ *
  */
 use Drupal\Core\Url;
 use Drupal\Component\Utility\Html;
@@ -22,6 +22,9 @@ function page_specific_class_preprocess_html(&$variables) {
 
   // Get settings from page specific class settings.
   $config = \Drupal::config('page_specific_class.settings');
+  // Check to see if this is empty.
+  if(empty($config->get('url_with_class'))) return;
+
   $enteredArr = explode(PHP_EOL, $config->get('url_with_class'));
 
   foreach ($enteredArr as $key => $values) {
@@ -32,7 +35,7 @@ function page_specific_class_preprocess_html(&$variables) {
     $front_page = \Drupal::service('path.matcher')->isFrontPage();
     $enteredPath = \Drupal::service('path.alias_manager')->getPathByAlias($url);
 
-    // If current path and entered path by user in page class setting match, 
+    // If current path and entered path by user in page class setting match,
     // then only add respective class.
     if ($current_path == $enteredPath) {
       foreach ($classes_array as $class) {
diff --git a/src/Form/PageSpecificClassSettingsForm.php b/src/Form/PageSpecificClassSettingsForm.php
index afaac16..e055383 100644
--- a/src/Form/PageSpecificClassSettingsForm.php
+++ b/src/Form/PageSpecificClassSettingsForm.php
@@ -56,8 +56,10 @@ class PageSpecificClassSettingsForm extends ConfigFormBase {
    * {@inheritdoc}
    */
   public function validateForm(array &$form, FormStateInterface $form_state) {
-
+    // Check to see if this is empty.
+    if(empty($form_state->getValue('url_with_class'))) return;
     $enteredArr = explode(PHP_EOL, $form_state->getValue('url_with_class'));
+
     foreach ($enteredArr as $key => $values) {
       $urlWithClassArr = explode("|", $values);
       $url = $urlWithClassArr[0];
-- 
2.23.0

