src/GoogleDriveAdapter.php
protected function setHasDir($targets, $object)
    {
        $service = $this->service;
        $client = $service->getClient();
        $gFiles = $service->files;
        $opts = [
            'pageSize' => 1
        ];
        $paths = [];
        $client->setUseBatch(true);
        $batch = $service->createBatch();
        $i = 0;
        foreach ($targets as $id) {
            $opts['q'] = sprintf('trashed = false and "%s" in parents and mimeType = "%s"', $id, self::DIRMIME);
            $request = $gFiles->listFiles($this->applyDefaultParams($opts, 'files.list'));
            $key = ++ $i;
            $batch->add($request, (string) $key);
            $paths['response-' . $key] = $id;
        }
        $results = $batch->execute();
        foreach ($results as $key => $result) {
            if ($result instanceof Google_Service_Drive_FileList) {
                $object[$paths[$key]]['hasdir'] = $this->cacheHasDirs[$paths[$key]] = (bool) $result->getFiles();
            }
        }
        $client->setUseBatch(false);
        return $object;
    }
protected function setHasDir($targets, $object)
    {
        $service = $this->service;
        $client = $service->getClient();
        $gFiles = $service->files;
        $opts = [
            'pageSize' => 1
        ];
        $paths = [];
        $client->setUseBatch(true);
        $batch = $service->createBatch();
        $i = 0;
        foreach ($targets as $id) {
            $opts['q'] = sprintf('trashed = false and "%s" in parents and mimeType = "%s"', $id, self::DIRMIME);
            $request = $gFiles->listFiles($this->applyDefaultParams($opts, 'files.list'));
            $key = ++ $i;
            $batch->add($request, (string) $key);
            $paths['response-' . $key] = $id;
        }
        $results = $batch->execute();
        foreach ($results as $key => $result) {
            if ($result instanceof Google_Service_Drive_FileList) {
                $object[$paths[$key]]['hasdir'] = $this->cacheHasDirs[$paths[$key]] = (bool) $result->getFiles();
            }
        }
        $client->setUseBatch(false);
        return $object;
    }
protected function setHasDir ( $ targets , $ object ) { $ service = $ this -> service ; $ client = $ service -> getClient ( ) ; $ gFiles = $ service -> files ; $ opts = [ 'pageSize' => 1 ] ; $ paths = [ ] ; $ client -> setUseBatch ( true ) ; $ batch = $ service -> createBatch ( ) ; $ i = 0 ; foreach ( $ targets as $ id ) { $ opts [ 'q' ] = sprintf ( 'trashed = false and "%s" in parents and mimeType = "%s"' , $ id , self :: DIRMIME ) ; $ request = $ gFiles -> listFiles ( $ this -> applyDefaultParams ( $ opts , 'files.list' ) ) ; $ key = ++ $ i ; $ batch -> add ( $ request , ( string ) $ key ) ; $ paths [ 'response-' . $ key ] = $ id ; } $ results = $ batch -> execute ( ) ; foreach ( $ results as $ key => $ result ) { if ( $ result instanceof Google_Service_Drive_FileList ) { $ object [ $ paths [ $ key ] ] [ 'hasdir' ] = $ this -> cacheHasDirs [ $ paths [ $ key ] ] = ( bool ) $ result -> getFiles ( ) ; } } $ client -> setUseBatch ( false ) ; return $ object ; }
Do cache cacheHasDirs with batch request

@param array $targets
[[path => id],...]

@return void
Do cache cacheHasDirs with batch request