summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-03-01 22:58:44 +0100
committerBart Visscher <bartv@thisnet.nl>2012-03-01 22:59:35 +0100
commitd1dcd7893cb878263b8179bab16d101036c57a88 (patch)
treec2759b3d1a862fed99144d79907d9b9628671d90 /lib
parent8c7b13db7011c8be986e9e525ca392bb13375432 (diff)
downloadnextcloud-server-d1dcd7893cb878263b8179bab16d101036c57a88.tar.gz
nextcloud-server-d1dcd7893cb878263b8179bab16d101036c57a88.zip
Search: Change provider registration to class name, for lazy loading of search providers
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php3
-rw-r--r--lib/search.php4
-rw-r--r--lib/search/provider.php8
-rw-r--r--lib/search/provider/file.php4
4 files changed, 6 insertions, 13 deletions
diff --git a/lib/base.php b/lib/base.php
index ee79f08eb22..336ff9fa231 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -350,6 +350,3 @@ if(!function_exists('get_temp_dir')) {
}
OC::init();
-
-// FROM search.php
-new OC_Search_Provider_File();
diff --git a/lib/search.php b/lib/search.php
index f6f805bfe65..6b33fa38140 100644
--- a/lib/search.php
+++ b/lib/search.php
@@ -29,7 +29,7 @@ class OC_Search{
/**
* register a new search provider to be used
- * @param OC_Search_Provider $provider
+ * @param string $provider class name of a OC_Search_Provider
*/
public static function registerProvider($provider){
self::$providers[]=$provider;
@@ -43,7 +43,7 @@ class OC_Search{
public static function search($query){
$results=array();
foreach(self::$providers as $provider){
- $results=array_merge($results,$provider->search($query));
+ $results=array_merge($results, $provider::search($query));
}
return $results;
}
diff --git a/lib/search/provider.php b/lib/search/provider.php
index cceed8b04a3..9487ca51f2b 100644
--- a/lib/search/provider.php
+++ b/lib/search/provider.php
@@ -2,15 +2,11 @@
/**
* provides search functionalty
*/
-abstract class OC_Search_Provider{
- public function __construct(){
- OC_Search::registerProvider($this);
- }
-
+interface OC_Search_Provider {
/**
* search for $query
* @param string $query
* @return array An array of OC_Search_Result's
*/
- abstract function search($query);
+ static function search($query);
}
diff --git a/lib/search/provider/file.php b/lib/search/provider/file.php
index a37af495599..3bdb3bcd2af 100644
--- a/lib/search/provider/file.php
+++ b/lib/search/provider/file.php
@@ -1,7 +1,7 @@
<?php
-class OC_Search_Provider_File extends OC_Search_Provider{
- function search($query){
+class OC_Search_Provider_File implements OC_Search_Provider{
+ static function search($query){
$files=OC_FileCache::search($query,true);
$results=array();
foreach($files as $fileData){