Skip to content

Commit

Permalink
Adding Asset Mapper support + new StimulusBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed May 22, 2023
1 parent b226b47 commit 28b7c6b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 2.9.0

- Add support for symfony/asset-mapper

## 2.8.0

- The autocomplete now watches for update to any `option` elements inside of
Expand Down
4 changes: 4 additions & 0 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"tom-select/dist/css/tom-select.bootstrap5.css": false
}
}
},
"importmap": {
"@hotwired/stimulus": "^3.0.0",
"tom-select": "^2.2.2"
}
},
"peerDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"require-dev": {
"doctrine/doctrine-bundle": "^2.4",
"doctrine/orm": "^2.9",
"mtdowling/jmespath.php": "2.6.x-dev",
"fakerphp/faker": "^1.22",
"mtdowling/jmespath.php": "^2.6",
"symfony/form": "^5.4|^6.0",
"symfony/framework-bundle": "^5.4|^6.0",
"symfony/maker-bundle": "^1.40",
Expand All @@ -45,7 +46,7 @@
"symfony/twig-bundle": "^5.4|^6.0",
"symfony/uid": "^5.4|^6.0",
"zenstruck/browser": "^1.1",
"zenstruck/foundry": "^1.19"
"zenstruck/foundry": "^1.32"
},
"conflict": {
"doctrine/orm": "2.9.0 || 2.9.1"
Expand Down
19 changes: 14 additions & 5 deletions src/DependencyInjection/AutocompleteExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\UX\Autocomplete\DependencyInjection;

use Symfony\Component\AssetMapper\AssetMapperInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
Expand Down Expand Up @@ -41,13 +42,21 @@ public function prepend(ContainerBuilder $container)
{
$bundles = $container->getParameter('kernel.bundles');

if (!isset($bundles['TwigBundle'])) {
return;
if (isset($bundles['TwigBundle'])) {
$container->prependExtensionConfig('twig', [
'form_themes' => ['@Autocomplete/autocomplete_form_theme.html.twig'],
]);
}

$container->prependExtensionConfig('twig', [
'form_themes' => ['@Autocomplete/autocomplete_form_theme.html.twig'],
]);
if (interface_exists(AssetMapperInterface::class)) {
$container->prependExtensionConfig('framework', [
'asset_mapper' => [
'paths' => [
__DIR__.'/../../assets/dist' => '@symfony/ux-autocomplete',
],
],
]);
}
}

public function load(array $configs, ContainerBuilder $container)
Expand Down

0 comments on commit 28b7c6b

Please sign in to comment.