Quellcode durchsuchen

Implement count and search correctly in FilterRepository

Jordi Boggiano vor 5 Jahren
Ursprung
Commit
6bed9d8f13
1 geänderte Dateien mit 14 neuen und 2 gelöschten Zeilen
  1. 14 2
      src/Composer/Repository/FilterRepository.php

+ 14 - 2
src/Composer/Repository/FilterRepository.php

@@ -133,7 +133,15 @@ class FilterRepository implements RepositoryInterface
      */
      */
     public function search($query, $mode = 0, $type = null)
     public function search($query, $mode = 0, $type = null)
     {
     {
-        return $this->repo->search($query, $mode, $type);
+        $result = array();
+
+        foreach ($this->repo->search($query, $mode, $type) as $package) {
+            if ($this->isAllowed($package['name'])) {
+                $result[] = $package;
+            }
+        }
+
+        return $result;
     }
     }
 
 
     /**
     /**
@@ -179,7 +187,11 @@ class FilterRepository implements RepositoryInterface
      */
      */
     public function count()
     public function count()
     {
     {
-        return $this->repo->count();
+        if ($this->repo->count() > 0) {
+            return count($this->getPackages());
+        }
+
+        return 0;
     }
     }
 
 
     private function isAllowed($name)
     private function isAllowed($name)