Implement search over description/keywords, refs #1801
parent
3a612dca01
commit
313b79ee13
|
@ -14,6 +14,7 @@ namespace Composer\Repository;
|
||||||
|
|
||||||
use Composer\Package\AliasPackage;
|
use Composer\Package\AliasPackage;
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
|
use Composer\Package\CompletePackageInterface;
|
||||||
use Composer\Package\Version\VersionParser;
|
use Composer\Package\Version\VersionParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,8 +85,12 @@ class ArrayRepository implements RepositoryInterface
|
||||||
$matches = array();
|
$matches = array();
|
||||||
foreach ($this->getPackages() as $package) {
|
foreach ($this->getPackages() as $package) {
|
||||||
$name = $package->getName();
|
$name = $package->getName();
|
||||||
// TODO implement SEARCH_FULLTEXT handling with keywords/description matching
|
if (isset($matches[$name])) {
|
||||||
if (!isset($matches[$name]) && preg_match($regex, $name)) {
|
continue;
|
||||||
|
}
|
||||||
|
if (preg_match($regex, $name)
|
||||||
|
|| ($mode === self::SEARCH_FULLTEXT && $package instanceof CompletePackageInterface && preg_match($regex, implode(' ', (array) $package->getKeywords()) . ' ' . $package->getDescription()))
|
||||||
|
) {
|
||||||
$matches[$name] = array(
|
$matches[$name] = array(
|
||||||
'name' => $package->getPrettyName(),
|
'name' => $package->getPrettyName(),
|
||||||
'description' => $package->getDescription(),
|
'description' => $package->getDescription(),
|
||||||
|
|
Loading…
Reference in New Issue