Skip to content

Commit

Permalink
Merge branch '1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdude committed Jan 5, 2021
2 parents e0e418e + 20ea605 commit 6c069e3
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 48 deletions.
33 changes: 4 additions & 29 deletions DependencyInjection/WebfactoryResponsiveImageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,14 @@ public function load(array $configs, ContainerBuilder $container)
}

public function prepend(ContainerBuilder $container)
{
$this->prependJbPhumborConfiguration($container);
}

/**
* @param ContainerBuilder $container
*/
private function prependJbPhumborConfiguration(ContainerBuilder $container)
{
$bundles = $container->getParameter('kernel.bundles');
if (!isset($bundles['JbPhumborBundle'])) {
return;
}

// Phumbor doesn't merge multiple configs, i.e. we have to consider only the first one
$originalConfig = $container->getExtensionConfig('jb_phumbor')[0];
$resultingConfig = $this->addConfigForEnvironment($originalConfig, null);

$environment = $container->getParameter('kernel.environment');
if (in_array($environment, ['development', 'testing', 'test'], true)) {
$resultingConfig = $this->addConfigForEnvironment($resultingConfig, $environment);
if (!isset($bundles['JbPhumborBundle'])) {
throw new \LogicException('WebfactoryResponsiveImageBundle requires that you also activate JbPhumborBundle (from jbouzekri/phumbor-bundle).');
}

$container->prependExtensionConfig('jb_phumbor', $resultingConfig);
}

private function addConfigForEnvironment(array $originalConfig, ?string $environment): array
{
$fileName = 'jb_phumbor-default-config'.($environment ? '_'.$environment : '').'.yaml';
$configToAdd = Yaml::parse(file_get_contents(__DIR__.'/../Resources/config/'.$fileName))['jb_phumbor'];

return is_array($configToAdd)
? array_replace_recursive($originalConfig, $configToAdd)
: $originalConfig;
$config = Yaml::parse(file_get_contents(__DIR__.'/../Resources/config/jb_phumbor-default-config.yaml'));
$container->prependExtensionConfig('jb_phumbor', $config['jb_phumbor']);
}
}
6 changes: 0 additions & 6 deletions Resources/config/jb_phumbor-default-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# each setting can be overwritten in your application
jb_phumbor:
server:
url: '%env(THUMBOR_URL)%'
secret: '%env(THUMBOR_SECURITY_KEY)%'

transformations:
image_thumb:
resize: { width: 80, height: 0 }
Expand Down Expand Up @@ -41,7 +37,6 @@ jb_phumbor:
resize: { width: 2400, height: 0 }
filters:
- { name: 'quality', arguments: [80] }

image_xxs--squared:
resize: { width: 320, height: 320 }
filters:
Expand Down Expand Up @@ -70,7 +65,6 @@ jb_phumbor:
resize: { width: 1600, height: 1600 }
filters:
- { name: 'quality', arguments: [80] }

image_xxs--blurred:
resize: { width: 320, height: 0 }
filters:
Expand Down
4 changes: 0 additions & 4 deletions Resources/config/jb_phumbor-default-config_development.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions Resources/config/jb_phumbor-default-config_test.yaml

This file was deleted.

1 change: 0 additions & 1 deletion Resources/config/jb_phumbor-default-config_testing.yaml

This file was deleted.

4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
"license": "MIT",
"require": {
"php": ">=5.5.9",
"jbouzekri/phumbor-bundle": "^2.2.0",
"twig/twig": "^1.35.4|^2.0",
"symfony/http-kernel": "^3.4.14 | ^4.4.1",
"symfony/config": "^3.4.14 | ^4.4.1",
"symfony/dependency-injection": "^3.4.14 | ^4.4.1",
"symfony/yaml": "^3.4.14 | ^4.4.1"
},
"suggest": {
"jbouzekri/phumbor-bundle": "Can be auto-configured with default transformations"
},
"autoload": {
"psr-4": {
"Webfactory\\ResponsiveImageBundle\\": "."
Expand Down

0 comments on commit 6c069e3

Please sign in to comment.