Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Gateways/Impl/FileGatewayImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use OpenClassrooms\Bundle\OneSkyBundle\Model\ExportFile;
use OpenClassrooms\Bundle\OneSkyBundle\Model\UploadFile;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Yaml\Yaml as SFYaml;
use Symfony\Component\HttpKernel\Exception\HttpException;

/**
* @author Romain Kuzniak <[email protected]>
Expand Down Expand Up @@ -58,7 +60,14 @@ private function downloadTranslation(ExportFile $file)
);
$downloadedContent = $this->client->translations(self::DOWNLOAD_METHOD, $file->format());
$this->checkTranslation($downloadedContent, $file);
file_put_contents($file->getTargetFilePath(), $downloadedContent);
if(!empty($downloadedContent)) {
if (is_callable("yaml_parse"))
file_put_contents($file->getTargetFilePath(), SFYaml::dump(yaml_parse($downloadedContent)));
else
throw new HttpException(500, "PHP YAML extension is missing ( https://pecl.php.net/package/yaml )");
}
else
file_put_contents($file->getTargetFilePath(), $downloadedContent);

return $file;
}
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ or by adding the package to the composer.json file directly:
}
```

This bundle need the YAML extension : https://pecl.php.net/package/yaml

#### PHP 7
```
apt-get install php-pear libyaml-dev
pecl install yaml-2.0.0
```
Add "extension=yaml.so" to php.ini for CLI

#### PHP 5
```
apt-get install php-pear libyaml-dev
pecl install yaml
```
Add "extension=yaml.so" to php.ini for CLI



After the package has been installed, add the bundle to the AppKernel.php file:
```php
// in AppKernel::registerBundles()
Expand Down