diff --git a/Classes/Domain/Model/Component.php b/Classes/Domain/Model/Component.php index 55f2472..6fc9fd3 100644 --- a/Classes/Domain/Model/Component.php +++ b/Classes/Domain/Model/Component.php @@ -162,9 +162,11 @@ public function getCodeQualityConfiguration(): ?string { $configurationFileLocations = [ $this->getLocation()->getDirectory(), - $this->getName()->getPackage()->getPath(), - rtrim($this->getName()->getPackage()->getExtension()->getPackagePath(), DIRECTORY_SEPARATOR) + ...$this->getName()->getPackage()->getPaths(), ]; + foreach($this->getName()->getPackage()->getExtensions() as $extension) { + $configurationFileLocations[] = rtrim($extension->getPackagePath(), DIRECTORY_SEPARATOR); + } foreach ($configurationFileLocations as $configurationFileLocation) { $configurationFile = $configurationFileLocation . DIRECTORY_SEPARATOR . '.fclint.json'; if (file_exists($configurationFile)) { diff --git a/Classes/Domain/Model/Package.php b/Classes/Domain/Model/Package.php index 4f43dc0..6a35075 100644 --- a/Classes/Domain/Model/Package.php +++ b/Classes/Domain/Model/Package.php @@ -6,18 +6,23 @@ use TYPO3\CMS\Core\Package\PackageInterface; use TYPO3\CMS\Core\Package\PackageManager; use TYPO3\CMS\Core\Utility\GeneralUtility; +use function array_values; class Package { /** - * Associated TYPO3 extension + * Associated TYPO3 extension(s) + * @var list|null */ - protected ?PackageInterface $extension = null; + protected ?array $extensions = null; public function __construct( protected string $namespace, // PHP namespace for the component package protected string $alias, // Fluid namespace alias for the component package - protected string $path, // Path for the component package + /** + * @var list Path for the component package + */ + protected array $paths, ) { $this->namespace = trim($namespace, '\\'); } @@ -32,26 +37,32 @@ public function getAlias(): string return $this->alias; } - public function getPath(): string + public function getPaths(): array { - return $this->path; + return $this->paths; } - public function getExtension(): ?PackageInterface + /** + * @return list returns first matching extension + */ + public function getExtensions(): array { - if ($this->extension) { - return $this->extension; + if ($this->extensions !== null) { + return $this->extensions; } + $extensions = []; $activeExtensions = GeneralUtility::makeInstance(PackageManager::class)->getActivePackages(); foreach ($activeExtensions as $extension) { - if (str_starts_with($this->getPath(), (string) $extension->getPackagePath())) { - $this->extension = $extension; - return $this->extension; + foreach ($this->getPaths() as $path) { + // Check if the package path starts with the extension's package path + if (str_starts_with($path, (string) $extension->getPackagePath())) { + $extensions[$extension->getPackagePath()] = $extension; + } } } - return null; + return $this->extensions = array_values($extensions); } /** diff --git a/Classes/Domain/Repository/PackageRepository.php b/Classes/Domain/Repository/PackageRepository.php index 4a42224..c064aa5 100644 --- a/Classes/Domain/Repository/PackageRepository.php +++ b/Classes/Domain/Repository/PackageRepository.php @@ -25,7 +25,7 @@ public function findAll(): array $fluidNamespaces = $this->getViewHelperResolver()->getNamespaces(); $componentNamespaces = $this->componentLoader->getNamespaces(); $packages = []; - foreach ($componentNamespaces as $namespace => $path) { + foreach ($componentNamespaces as $namespace => $paths) { $matchingNamespaceAlias = '???'; foreach ($fluidNamespaces as $namespaceAlias => $namespaceCandidates) { if (in_array($namespace, $namespaceCandidates)) { @@ -33,11 +33,10 @@ public function findAll(): array break; } } - $packages[] = new Package( $namespace, $matchingNamespaceAlias, - $path + $paths ); } diff --git a/README.md b/README.md index b7e18df..2154513 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ To add your own components to the styleguide, just follow these additional steps Make sure to define the component namespace in your **ext_localconf.php**: ```php - $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['fluid_components']['namespaces']['VENDOR\\MyExtension\\Components'] = + $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['fluid_components']['namespaces']['VENDOR\\MyExtension\\Components'][] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('my_extension', 'Resources/Private/Components'); ``` diff --git a/ext_localconf.php b/ext_localconf.php index e9f7d01..922287e 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,7 +1,9 @@