From 22514765e42a1aa56f43cfe787c3673329fc20b8 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 1 Mar 2013 13:55:27 -0500
Subject: [PATCH] Created initialization mechanism for Options/Params objects.

---
 module/VuFind/src/VuFind/Search/Base/Options.php | 10 ++++++++++
 module/VuFind/src/VuFind/Search/Base/Params.php  | 10 ++++++++++
 module/VuFind/src/VuFind/Search/Manager.php      |  2 ++
 3 files changed, 22 insertions(+)

diff --git a/module/VuFind/src/VuFind/Search/Base/Options.php b/module/VuFind/src/VuFind/Search/Base/Options.php
index 5c501f8ff78..d7e933dd925 100644
--- a/module/VuFind/src/VuFind/Search/Base/Options.php
+++ b/module/VuFind/src/VuFind/Search/Base/Options.php
@@ -126,6 +126,16 @@ abstract class Options implements ServiceLocatorAwareInterface
         $this->limitOptions = array($this->defaultLimit);
     }
 
+    /**
+     * Perform initialization that cannot occur in constructor due to need for
+     * injected dependencies.
+     *
+     * @return void
+     */
+    public function init()
+    {
+    }
+
     /**
      * Get string listing special advanced facet types.
      *
diff --git a/module/VuFind/src/VuFind/Search/Base/Params.php b/module/VuFind/src/VuFind/Search/Base/Params.php
index 3d369a8cddd..a3887561c35 100644
--- a/module/VuFind/src/VuFind/Search/Base/Params.php
+++ b/module/VuFind/src/VuFind/Search/Base/Params.php
@@ -86,6 +86,16 @@ class Params implements ServiceLocatorAwareInterface
         }
     }
 
+    /**
+     * Perform initialization that cannot occur in constructor due to need for
+     * injected dependencies.
+     *
+     * @return void
+     */
+    public function init()
+    {
+    }
+
     /**
      * Get the search options object.
      *
diff --git a/module/VuFind/src/VuFind/Search/Manager.php b/module/VuFind/src/VuFind/Search/Manager.php
index 7fa4554d9bc..ca4b670bf9e 100644
--- a/module/VuFind/src/VuFind/Search/Manager.php
+++ b/module/VuFind/src/VuFind/Search/Manager.php
@@ -164,6 +164,7 @@ class Manager implements ServiceLocatorAwareInterface
                 throw new \Exception('Invalid options object.');
             }
             $this->injectDependencies($this->optionsStore[$this->classId]);
+            $this->optionsStore[$this->classId]->init();
         }
         return $this->optionsStore[$this->classId];
     }
@@ -184,6 +185,7 @@ class Manager implements ServiceLocatorAwareInterface
             throw new \Exception('Invalid params object.');
         }
         $this->injectDependencies($params);
+        $params->init();
         return $params;
     }
 
-- 
GitLab