Skip to content

[StimulusBundle] UxPackageReader class doesn't support projects with varied structures using Composer with custom directory structure #1467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2024
Merged
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
9 changes: 8 additions & 1 deletion src/StimulusBundle/src/Ux/UxPackageReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\UX\StimulusBundle\Ux;

use Composer\InstalledVersions;

/**
* @internal
*
Expand All @@ -28,7 +30,12 @@ public function readPackageMetadata(string $packageName): UxPackageMetadata
{
// remove the '@' from the name to get back to the PHP package name
$phpPackageName = substr($packageName, 1);
$phpPackagePath = $this->projectDir.'/vendor/'.$phpPackageName;
if (class_exists(InstalledVersions::class) && InstalledVersions::isInstalled($phpPackageName)) {
$phpPackagePath = InstalledVersions::getInstallPath($phpPackageName);
} else {
$phpPackagePath = $this->projectDir.'/vendor/'.$phpPackageName;
}

if (!is_dir($phpPackagePath)) {
throw new \RuntimeException(sprintf('Could not find package "%s" referred to from controllers.json.', $phpPackageName));
}
Expand Down