Skip to content

Commit

Permalink
Merge pull request #176 from liip/override_device_detection
Browse files Browse the repository at this point in the history
make it possible to override the device detection service
  • Loading branch information
lsmith77 authored Dec 17, 2017
2 parents 600ac26 + f9ef512 commit 4dc77f8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function getConfigTreeBuilder()
->end()
->end()
->scalarNode('autodetect_theme')->defaultFalse()->end()
->scalarNode('device_detection')->defaultFalse()->end()
->booleanNode('cache_warming')->defaultTrue()->end()
->booleanNode('load_controllers')->defaultTrue()->end()
->booleanNode('assetic_integration')->defaultFalse()->end()
Expand Down
6 changes: 6 additions & 0 deletions DependencyInjection/LiipThemeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@ public function load(array $configs, ContainerBuilder $container)
->addTag('kernel.event_listener', array('event' => 'kernel.response', 'method' => 'onKernelResponse'));
}

if (!empty($config['device_detection'])) {
$container->setAlias('liip_theme.theme_auto_detect', $config['device_detection']);
}

if (!empty($config['autodetect_theme'])) {
// @FIXME for 2.0 we should make 'autodetect_theme' a boolean only
$id = is_string($config['autodetect_theme']) ? $config['autodetect_theme'] : 'liip_theme.theme_auto_detect';

$container->getDefinition($this->getAlias().'.theme_request_listener')
->addArgument(new Reference($id));
}
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,22 @@ ensuring that all of the assets are dumped.

Note that this only works with AsseticBundle 2.1 or higher.

### Override the Device Detection

It is possible to override the service used for the device detection. Make sure to either
extend `DeviceDetection` or implement `DeviceDetectionInterface`:

````yaml
# app/config/config.yml
services:
my_devcice_detection:
class: SomeClass

liip_theme:
# ...
device_detection: my_devcice_detection
````

## Contribution

Active contribution and patches are very welcome. To keep things in shape we
Expand Down

0 comments on commit 4dc77f8

Please sign in to comment.