Skip to content

Commit

Permalink
remove deprecated options and fix absolute_url errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lhapaipai committed Oct 22, 2023
1 parent 0ecb0d6 commit 48f8936
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 27 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v5.0.1

- remove deprecated options
- fix `absolute_url` error in `shouldUseAbsoluteURL`.

## v4.3.0

- add `absolute_url` bundle option.
Expand Down
2 changes: 1 addition & 1 deletion src/Asset/EntrypointRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private function shouldUseAbsoluteURL(array $options, $buildName)
{
$viteServer = $this->entrypointsLookup->getViteServer($buildName);

return false === $viteServer && $this->useAbsoluteUrl || (isset($options['absolute_url']) && true === $options['absolute_url']);
return false === $viteServer && ($this->useAbsoluteUrl || (isset($options['absolute_url']) && true === $options['absolute_url']));
}

public function renderLinks(string $entryName, array $options = [], $buildName = null): string
Expand Down
14 changes: 2 additions & 12 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Pentatrion\ViteBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

Expand All @@ -10,18 +11,11 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('pentatrion_vite');
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();

$rootNode
->children()
->scalarNode('public_dir')
->defaultValue('public')
->setDeprecated('pentatrion/vite-bundle', '3.3.1', 'The "%node%" option is deprecated. Use "public_directory" instead.')
->end()
->scalarNode('base')
->defaultValue('/build/')
->setDeprecated('pentatrion/vite-bundle', '3.3.1', 'The "%node%" option is deprecated. Use "build_directory" instead.')
->end()
->scalarNode('public_directory')
->defaultValue('public')
->end()
Expand Down Expand Up @@ -61,10 +55,6 @@ public function getConfigTreeBuilder(): TreeBuilder
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->scalarNode('base')
->defaultValue('/build/')
->setDeprecated('pentatrion/vite-bundle', '3.3.1', 'The "%node%" option is deprecated. Use "build_directory" instead.')
->end()
->scalarNode('build_directory')
->defaultValue('build')
->end()
Expand Down
14 changes: 0 additions & 14 deletions src/DependencyInjection/PentatrionViteExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ public function load(array $configs, ContainerBuilder $container): void
$defaultBuild = $config['default_build'];
$builds = [];
foreach ($config['builds'] as $buildName => $build) {
if ('build' === $build['build_directory'] && '/build/' !== $build['base']) {
$build['build_directory'] = $build['base'];
}

$builds[$buildName] = [
'base' => self::prepareBase($build['build_directory']),
'script_attributes' => $build['script_attributes'],
Expand All @@ -55,11 +51,6 @@ public function load(array $configs, ContainerBuilder $container): void
}
} else {
$defaultBuild = 'default';

if ('build' === $config['build_directory'] && '/build/' !== $config['base']) {
$config['build_directory'] = $config['base'];
}

$builds = [
'default' => [
'base' => self::prepareBase($config['build_directory']),
Expand All @@ -69,11 +60,6 @@ public function load(array $configs, ContainerBuilder $container): void
];
}

// if deprecated option is set and not `public_directory`.
if ('public' === $config['public_directory'] && 'public' !== $config['public_dir']) {
$config['public_directory'] = $config['public_dir'];
}

$container->setParameter('pentatrion_vite.public_directory', self::preparePublicDirectory($config['public_directory']));
$container->setParameter('pentatrion_vite.default_build', $defaultBuild);
$container->setParameter('pentatrion_vite.builds', $builds);
Expand Down

0 comments on commit 48f8936

Please sign in to comment.