Intermediary commit
authorIRI
Wed, 31 Mar 2010 11:57:07 +0200
changeset 37 47df1cde32e9
parent 34 99497716e36d
child 38 66b32754f6b0
Intermediary commit
.hgignore
web/thdProject/lib/model/doctrine/ThdDoctrineListener.class.php
web/thdProject/plugins/iriSonyenginePlugin/config/iriSonyenginePluginConfiguration.class.php
web/thdProject/plugins/iriSonyenginePlugin/config/sonyengine.yml.tmpl
web/thdProject/plugins/iriSonyenginePlugin/lib/iriSonyengineEventListener.class.php
web/thdProject/plugins/uvmcSolrSearchPlugin/config/solr.yml
web/thdProject/plugins/uvmcSolrSearchPlugin/config/solr.yml.tmpl
web/thdProject/plugins/uvmcSolrSearchPlugin/config/uvmcSolrSearchPluginConfiguration.class.php
--- a/.hgignore	Wed Mar 31 10:33:40 2010 +0200
+++ b/.hgignore	Wed Mar 31 11:57:07 2010 +0200
@@ -24,4 +24,8 @@
 ^web/thdProject/desktop\.ini$
 
 syntax: regexp
-^engine/sonyengine/context\.xml$
\ No newline at end of file
+^engine/sonyengine/context\.xml$
+syntax: regexp
+^web/thdProject/plugins/uvmcSolrSearchPlugin/config/solr\.yml$
+syntax: regexp
+^web/thdProject/plugins/iriSonyenginePlugin/config/sonyengine\.yml$
\ No newline at end of file
--- a/web/thdProject/lib/model/doctrine/ThdDoctrineListener.class.php	Wed Mar 31 10:33:40 2010 +0200
+++ b/web/thdProject/lib/model/doctrine/ThdDoctrineListener.class.php	Wed Mar 31 11:57:07 2010 +0200
@@ -5,6 +5,12 @@
   public function postInsert(Doctrine_Event $event) {
     $obj = $event->getInvoker();
 
+    if (method_exists($obj, 'getSolrDocumentFields'))
+    {
+        $dispatcher = sfContext::getInstance()->getEventDispatcher();
+		$dispatcher->notify(new sfEvent($mySubject, 'uvmc_solr.add_document', array('object' => $obj, 'commit' => true)));
+    }
+    
     // Index in solr
     sfContext::getInstance()->getLogger()->info("Insert object. Index in solr");
   }
@@ -12,7 +18,22 @@
   public function postUpdate(Doctrine_Event $event) {
     $obj = $event->getInvoker();
 
+    if (method_exists($obj, 'getSolrDocumentFields'))
+    {
+        $dispatcher = sfContext::getInstance()->getEventDispatcher();
+		$dispatcher->notify(new sfEvent($mySubject, 'uvmc_solr.update_document', array('object' => $obj, 'commit' => true)));
+    }
+    
     // Reindex in solr
     sfContext::getInstance()->getLogger()->info("Update object. Reindex in solr");
   }
+  
+  public function preDelete(Doctrine_Event $event) {
+  		$obj = $event->getInvoker();
+  		if (method_exists($obj, 'getSolrDocumentFields'))
+    	{
+        	$dispatcher = sfContext::getInstance()->getEventDispatcher();
+			$dispatcher->notify(new sfEvent($mySubject, 'uvmc_solr.delete_document', array('object' => $obj, 'commit' => true)));
+   	 	} 		
+  }
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/plugins/iriSonyenginePlugin/config/iriSonyenginePluginConfiguration.class.php	Wed Mar 31 11:57:07 2010 +0200
@@ -0,0 +1,42 @@
+<?php
+
+/**
+ * @package     uvmcSolrSearchPlugin
+ * @subpackage  configuration
+ * @author      Marc Weistroff <mweistroff@uneviemoinschere.com>
+ * @version     $Id: uvmcSolrSearchPluginConfiguration.class.php 21181 2009-08-17 08:18:16Z futurecat $
+ */
+class iriSonyenginePluginConfiguration extends sfPluginConfiguration
+{
+  public function initialize()
+  {
+    if($this->configuration instanceof sfApplicationConfiguration)
+    {
+      $configCache = $this->configuration->getConfigCache();
+      $configCache->registerConfigHandler('config/sonyengine.yml', 'sfDefineEnvironmentConfigHandler', array('prefix' => 'iri_sonyengine_'));
+      require_once($configCache->checkConfig('config/sonyengine.yml'));
+    }
+
+    $isEnabled = sfConfig::get('iri_sonyengine_enabled', false);
+    $isEnabled = $isEnabled == true || $isEnabled == 'on' ? true : false;
+
+    if ($isEnabled)
+    {
+      $this->connectEvents();
+    }
+  }
+
+  /**
+   * Connect events to listeners
+   */
+  public function connectEvents()
+  {
+    $this->dispatcher->connect('iri_sonyengine.search', array('uvmcSolrEventListener', 'listenToSearch'));
+    $this->dispatcher->connect('iri_sonyengine.commit', array('uvmcSolrEventListener', 'listenToCommit'));
+    $this->dispatcher->connect('iri_sonyengine.add_document', array('uvmcSolrEventListener', 'listenToAddDocument'));
+    $this->dispatcher->connect('iri_sonyengine.update_document', array('uvmcSolrEventListener', 'listenToAddDocument'));
+    $this->dispatcher->connect('iri_sonyengine.delete_document', array('uvmcSolrEventListener', 'listenToDeleteDocument'));
+    $this->dispatcher->connect('iri_sonyengine.add_document_to_collection', array('uvmcSolrEventListener', 'listenToAddDocumentToCollection'));
+    $this->dispatcher->connect('iri_sonyengine.add_collection', array('uvmcSolrEventListener', 'listenToAddCollection'));
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/plugins/iriSonyenginePlugin/config/sonyengine.yml.tmpl	Wed Mar 31 11:57:07 2010 +0200
@@ -0,0 +1,11 @@
+# uvmcSolrSearchPlugin configuration file
+# solr.yml can be configured at application level
+# prefix: iri_sonyengine_
+#
+
+all:
+  enabled:        on                    
+  service:
+    host:         localhost
+    port:         8080
+    path:         "/sonyengine"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/plugins/iriSonyenginePlugin/lib/iriSonyengineEventListener.class.php	Wed Mar 31 11:57:07 2010 +0200
@@ -0,0 +1,17 @@
+<?php
+
+class iriSonyengineEventListener
+{
+	static function listenToSearch(sfEvent $event) {
+		
+		$segment = $event["segment"];
+		$tag = $event["tag"];
+		$distance = $event["distance"];
+		if(!isset($event["more"]))
+		    $more = "false";
+		else
+			$more = $event["more"]?"true":"false";
+		
+		
+	}
+}
\ No newline at end of file
--- a/web/thdProject/plugins/uvmcSolrSearchPlugin/config/solr.yml	Wed Mar 31 10:33:40 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-# uvmcSolrSearchPlugin configuration file
-# solr.yml can be configured at application level
-# prefix: uvmc_solr_
-#
-#
-
-all:
-  enabled:        on                    
-  service:
-    host:         localhost
-    port:         8080
-    path:         "/mosatags"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/plugins/uvmcSolrSearchPlugin/config/solr.yml.tmpl	Wed Mar 31 11:57:07 2010 +0200
@@ -0,0 +1,12 @@
+# uvmcSolrSearchPlugin configuration file
+# solr.yml can be configured at application level
+# prefix: uvmc_solr_
+#
+#
+
+all:
+  enabled:        on                    
+  service:
+    host:         localhost
+    port:         8080
+    path:         "/solr"
\ No newline at end of file
--- a/web/thdProject/plugins/uvmcSolrSearchPlugin/config/uvmcSolrSearchPluginConfiguration.class.php	Wed Mar 31 10:33:40 2010 +0200
+++ b/web/thdProject/plugins/uvmcSolrSearchPlugin/config/uvmcSolrSearchPluginConfiguration.class.php	Wed Mar 31 11:57:07 2010 +0200
@@ -31,8 +31,8 @@
    */
   public function connectEvents()
   {
-    $this->dispatcher->connect('admin.save_object', array('uvmcSolrEventListener', 'listenToAdminSaveObject'));
-    $this->dispatcher->connect('admin.delete_object', array('uvmcSolrEventListener', 'listenToAdminDeleteObject'));
+    //$this->dispatcher->connect('admin.save_object', array('uvmcSolrEventListener', 'listenToAdminSaveObject'));
+    //$this->dispatcher->connect('admin.delete_object', array('uvmcSolrEventListener', 'listenToAdminDeleteObject'));
     $this->dispatcher->connect('uvmc_solr.search', array('uvmcSolrEventListener', 'listenToSearch'));
     $this->dispatcher->connect('uvmc_solr.commit', array('uvmcSolrEventListener', 'listenToCommit'));
     $this->dispatcher->connect('uvmc_solr.add_document', array('uvmcSolrEventListener', 'listenToAddDocument'));