public function findPackages($searches = [])
    {
        $packages = ['total' => 0, 'not_found' => []];
        $inflector = new Inflector();

        foreach ($searches as $search) {
            $repository = '';
            // if this is an object, get the search data from the key
            if (is_object($search)) {
                $search = (array)$search;
                $key = key($search);
                $repository = $search[$key];
                $search = $key;
            }

            $found = $this->findPackage($search);
            if ($found) {
                // set override repository if provided
                if ($repository) {
                    $found->override_repository = $repository;
                }
                if (!isset($packages[$found->package_type])) {
                    $packages[$found->package_type] = [];
                }

                $packages[$found->package_type][$found->slug] = $found;
                $packages['total']++;
            } else {
                // make a best guess at the type based on the repo URL
                if (Utils::contains($repository, '-theme')) {
                    $type = 'themes';
                } else {
                    $type = 'plugins';
                }

                $not_found = new \stdClass();
                $not_found->name = $inflector::camelize($search);
                $not_found->slug = $search;
                $not_found->package_type = $type;
                $not_found->install_path = str_replace('%name%', $search, $this->install_paths[$type]);
                $not_found->override_repository = $repository;
                $packages['not_found'][$search] = $not_found;
            }
        }

        return $packages;
    }
public function findPackages($searches = [])
    {
        $packages = ['total' => 0, 'not_found' => []];
        $inflector = new Inflector();

        foreach ($searches as $search) {
            $repository = '';
            // if this is an object, get the search data from the key
            if (is_object($search)) {
                $search = (array)$search;
                $key = key($search);
                $repository = $search[$key];
                $search = $key;
            }

            $found = $this->findPackage($search);
            if ($found) {
                // set override repository if provided
                if ($repository) {
                    $found->override_repository = $repository;
                }
                if (!isset($packages[$found->package_type])) {
                    $packages[$found->package_type] = [];
                }

                $packages[$found->package_type][$found->slug] = $found;
                $packages['total']++;
            } else {
                // make a best guess at the type based on the repo URL
                if (Utils::contains($repository, '-theme')) {
                    $type = 'themes';
                } else {
                    $type = 'plugins';
                }

                $not_found = new \stdClass();
                $not_found->name = $inflector::camelize($search);
                $not_found->slug = $search;
                $not_found->package_type = $type;
                $not_found->install_path = str_replace('%name%', $search, $this->install_paths[$type]);
                $not_found->override_repository = $repository;
                $packages['not_found'][$search] = $not_found;
            }
        }

        return $packages;
    }
public function findPackages ( $ searches = [ ] ) { $ packages = [ 'total' => 0 , 'not_found' => [ ] ] ; $ inflector = new Inflector ( ) ; foreach ( $ searches as $ search ) { $ repository = '' ; // if this is an object, get the search data from the key if ( is_object ( $ search ) ) { $ search = ( array ) $ search ; $ key = key ( $ search ) ; $ repository = $ search [ $ key ] ; $ search = $ key ; } $ found = $ this -> findPackage ( $ search ) ; if ( $ found ) { // set override repository if provided if ( $ repository ) { $ found -> override_repository = $ repository ; } if ( ! isset ( $ packages [ $ found -> package_type ] ) ) { $ packages [ $ found -> package_type ] = [ ] ; } $ packages [ $ found -> package_type ] [ $ found -> slug ] = $ found ; $ packages [ 'total' ] ++ ; } else { // make a best guess at the type based on the repo URL if ( Utils :: contains ( $ repository , '-theme' ) ) { $ type = 'themes' ; } else { $ type = 'plugins' ; } $ not_found = new \ stdClass ( ) ; $ not_found -> name = $ inflector :: camelize ( $ search ) ; $ not_found -> slug = $ search ; $ not_found -> package_type = $ type ; $ not_found -> install_path = str_replace ( '%name%' , $ search , $ this -> install_paths [ $ type ] ) ; $ not_found -> override_repository = $ repository ; $ packages [ 'not_found' ] [ $ search ] = $ not_found ; } } return $ packages ; }
Searches for a list of Packages in the repository
@param  array $searches An array of either slugs or names
@return array Array of found Packages
Format: ['total' => int, 'not_found' => array, <found-slugs>]
Searches for a list of Packages in the repository