mirror of
https://github.com/composer/composer
synced 2025-05-11 09:32:55 +00:00
Added --type option to search
This commit is contained in:
parent
5a3d60c0cf
commit
6a557e45b8
7 changed files with 110 additions and 11 deletions
|
@ -89,7 +89,7 @@ class ArrayRepository extends BaseRepository
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function search($query, $mode = 0)
|
||||
public function search($query, $mode = 0, $type = null)
|
||||
{
|
||||
$regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
|
||||
|
||||
|
@ -102,9 +102,13 @@ class ArrayRepository extends BaseRepository
|
|||
if (preg_match($regex, $name)
|
||||
|| ($mode === self::SEARCH_FULLTEXT && $package instanceof CompletePackageInterface && preg_match($regex, implode(' ', (array) $package->getKeywords()) . ' ' . $package->getDescription()))
|
||||
) {
|
||||
if (null !== $type && $package->getType() !== $type) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$matches[$name] = array(
|
||||
'name' => $package->getPrettyName(),
|
||||
'description' => $package->getDescription(),
|
||||
'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue