/** * {@inheritdoc} */ public function load(ClassMetadata $metadata, ParserInterface $parser) { $this->finder->files()->in($this->dir); $content = array(); foreach ($this->finder as $file) { $content[] = $parser->parse($metadata, $file->getRelativePathname(), $file->getContents()); } return $content; }
/** * {@inheritdoc} */ public function load(ClassMetadata $metadata, ParserInterface $parser) { // Create a request with basic Auth $request = $this->client->get('metadata/dropbox/' . $this->path); try { // Send the request and get the response. $response = $request->send(); } catch (ClientErrorResponseException $e) { $this->handleBadResponseExceptions($e); } $responseBody = $response->json(); $batch = array(); foreach ($responseBody['contents'] as $file) { $batch[] = $this->client->get('https://api-content.dropbox.com/1/files/dropbox' . $file['path']); } try { $responses = $this->client->send($batch); } catch (MultiTransferException $e) { $this->handleBadResponseExceptions($e->getFirst()); } $content = array(); foreach ($responses as $response) { $url = parse_url($response->getEffectiveUrl()); $filename = basename($url['path']); $receivedContent = $response->getBody(true); $content[] = $parser->parse($metadata, $filename, $receivedContent); } return $content; }
/** * {@inheritdoc} */ public function load(ClassMetadata $metadata, ParserInterface $parser) { // Create a request with basic Auth $request = $this->client->get('repos/' . $this->owner . '/' . $this->repository . '/contents'); try { // Send the request and get the response. $response = $request->send(); } catch (ClientErrorResponseException $e) { $this->handleBadResponseExceptions($e); } $files = $response->json(); $batch = array(); foreach ($files as $file) { $batch[] = $this->client->get('repos/' . $this->owner . '/' . $this->repository . '/contents/' . $file['path']); } try { $responses = $this->client->send($batch); } catch (MultiTransferException $e) { $this->handleBadResponseExceptions($e->getFirst()); } $content = array(); foreach ($responses as $response) { $file = $response->json(); $decodedContent = base64_decode($file['content']); $content[] = $parser->parse($metadata, $file['name'], $decodedContent); } return $content; }
/** * {@inheritdoc} */ public function load(ClassMetadata $metadata, ParserInterface $parser) { $content = array(); $tempFile = tmpfile(); $response = $this->client->get($this->url, null, $tempFile)->send(); $zipFile = $response->getBody()->getUri(); $zip = zip_open($zipFile); if (!is_resource($zip)) { throw new RuntimeException(sprintf('Something went wrong when opening %s.', $zipFile)); } while ($zipEntry = zip_read($zip)) { $fileName = zip_entry_name($zipEntry); $fileSize = zip_entry_filesize($zipEntry); $fileContent = zip_entry_read($zipEntry, $fileSize); if ($fileContent) { $content[] = $parser->parse($metadata, basename($fileName), $fileContent); } } zip_close($zip); return $content; }