Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions Classes/Domain/Model/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
35 changes: 23 additions & 12 deletions Classes/Domain/Model/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<PackageInterface>|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<string> Path for the component package
*/
protected array $paths,
) {
$this->namespace = trim($namespace, '\\');
}
Expand All @@ -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<PackageInterface> 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);
}

/**
Expand Down
5 changes: 2 additions & 3 deletions Classes/Domain/Repository/PackageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,18 @@ 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)) {
$matchingNamespaceAlias = $namespaceAlias;
break;
}
}

$packages[] = new Package(
$namespace,
$matchingNamespaceAlias,
$path
$paths
);
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');
```

Expand Down
6 changes: 4 additions & 2 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

call_user_func(function () {
// Register component namespace
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['fluid_components']['namespaces']['Sitegeist\\FluidStyleguide\\Components'] =
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('fluid_styleguide', 'Resources/Private/Components');
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['fluid_components']['namespaces']['Sitegeist\\FluidStyleguide\\Components'][] =
ExtensionManagementUtility::extPath('fluid_styleguide', 'Resources/Private/Components');
});