Skip to content

Commit

Permalink
Merge pull request #1670 from spryker-shop/feature/ae-147/master-feat…
Browse files Browse the repository at this point in the history
…ure-module-ssp

FRW-9645 nonsplit to split merge
  • Loading branch information
asmarovydlo authored Jan 7, 2025
2 parents 8ba709a + 954c0a8 commit c4a6ba3
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 42 deletions.
74 changes: 37 additions & 37 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/Shared/config_default.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
];
$config[KernelConstants::CORE_NAMESPACES] = [
'SprykerShop',
'SprykerFeature',
'SprykerEco',
'Spryker',
'SprykerSdk',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/**
* This file is part of the Spryker Suite.
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

declare(strict_types = 1);

namespace Pyz\Zed\DocumentationGeneratorRestApi\Business;

use Pyz\Zed\DocumentationGeneratorRestApi\Business\Finder\GlueControllerFinder;
use Spryker\Zed\DocumentationGeneratorRestApi\Business\DocumentationGeneratorRestApiBusinessFactory as SprykerDocumentationGeneratorRestApiBusinessFactory;
use Spryker\Zed\DocumentationGeneratorRestApi\Business\Finder\GlueControllerFinderInterface;

/**
* @method \Pyz\Zed\DocumentationGeneratorRestApi\DocumentationGeneratorRestApiConfig getConfig()
*/
class DocumentationGeneratorRestApiBusinessFactory extends SprykerDocumentationGeneratorRestApiBusinessFactory
{
/**
* @return \Spryker\Zed\DocumentationGeneratorRestApi\Business\Finder\GlueControllerFinderInterface
*/
public function createGlueControllerFinder(): GlueControllerFinderInterface
{
return new GlueControllerFinder(
$this->getFinder(),
$this->getTextInflector(),
$this->getConfig()->getAnnotationSourceDirectories(),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

/**
* This file is part of the Spryker Suite.
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

declare(strict_types = 1);

namespace Pyz\Zed\DocumentationGeneratorRestApi\Business\Finder;

use Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRoutePluginInterface;
use Spryker\Zed\DocumentationGeneratorRestApi\Business\Finder\GlueControllerFinder as SprykerGlueControllerFinder;

class GlueControllerFinder extends SprykerGlueControllerFinder
{
/**
* @param \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRoutePluginInterface $plugin
*
* @return array<\SplFileInfo>
*/
public function getGlueControllerFilesFromPlugin(ResourceRoutePluginInterface $plugin): array
{
$controllerNamespace = $this->getPluginControllerClass($plugin);
$controllerNamespaceExploded = explode('\\', $controllerNamespace);

$moduleName = array_slice($controllerNamespaceExploded, -3)[0];
$existingDirectories = $this->getMonoRepositoryControllerSourceDirectories($moduleName, $moduleName);
if (!$existingDirectories) {
$existingDirectories = $this->getMonoRepositoryControllerSourceDirectories(
$this->toSingular($this->removeRestApiSuffix($moduleName)),
$moduleName,
);
}

if (!$existingDirectories) {
return [];
}

$finder = clone $this->finder;
$finder->in($existingDirectories)->name(sprintf(static::PATTERN_CONTROLLER_FILENAME, end($controllerNamespaceExploded)));

return iterator_to_array($finder);
}

/**
* @param string $moduleDirectory
* @param string $moduleName
*
* @return array<string>
*/
protected function getMonoRepositoryControllerSourceDirectories(string $moduleDirectory, string $moduleName): array
{
$directories = array_map(function ($directory) use ($moduleDirectory, $moduleName) {
return sprintf($directory, $moduleDirectory, $moduleName);
}, $this->sourceDirectories);

return $this->getExistingSourceDirectories($directories);
}

/**
* @param string $moduleName
*
* @return string
*/
protected function removeRestApiSuffix(string $moduleName): string
{
return str_replace('RestApi', '', $moduleName);
}

/**
* @param string $moduleName
*
* @return string
*/
protected function toSingular(string $moduleName): string
{
$rules = [
'/(s|x|z|ch|sh)es$/i' => '$1',
'/ies$/i' => 'y',
'/ves$/i' => 'f',
'/s$/i' => '',
];

foreach ($rules as $pattern => $replacement) {
if (preg_match($pattern, $moduleName)) {
return preg_replace($pattern, $replacement, $moduleName);
}
}

return $moduleName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'SprykerShop',
'SprykerEco',
'Spryker',
'SprykerFeature',
];

$config[KernelConstants::PROJECT_NAMESPACE] = 'Pyz';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ validateModuleTransfers() {

let "TRANSFER_TOTAL_MODULES_PROCESSED_COUNT+=1"

echo $2.$module
output=$(vendor/bin/spryker-dev-console dev:validate-module-transfers -v -m $2.$module)
echo $module
output=$(vendor/bin/spryker-dev-console dev:validate-module-transfers -v -m $module)
if [ $? -ne 0 ]; then
echo $output
EXITCODE=1
Expand Down Expand Up @@ -63,8 +63,8 @@ validateModuleArchitecture() {

let "ARCHITECTURE_TOTAL_MODULES_PROCESSED_COUNT+=1"

echo $2.$module
output=$(vendor/bin/console code:sniff:architecture -v -m $2.$module)
echo $module
output=$(vendor/bin/console code:sniff:architecture -v -m $module)
if [ $? -ne 0 ]; then
echo $output
EXITCODE=1
Expand Down
File renamed without changes.
12 changes: 11 additions & 1 deletion tests/touched_modules_list.sh
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
echo $(git -C vendor/spryker/$1 diff --name-only --diff-filter=ACMRTUXB master... | grep "^Bundles\/" | cut -d "/" -f2- | cut -d "/" -f1 | sort | uniq)
modules=$(git -C vendor/spryker/$1 diff --name-only --diff-filter=ACMRTUXB master... | grep -E "^Bundles\/|^Features\/" | cut -d "/" -f2- | cut -d "/" -f1 | sort | uniq)

for module in $modules; do
if git -C vendor/spryker/$1 diff --name-only --diff-filter=ACMRTUXB master... | grep -q "^Bundles\/$module"; then
echo "Spryker.$module"
elif git -C vendor/spryker/$1 diff --name-only --diff-filter=ACMRTUXB master... | grep -q "^Features\/$module"; then
if [[ -d "Features/$module/src/" || -d "Features/$module/tests/" ]]; then
echo "SprykerFeature.$module"
fi
fi
done

0 comments on commit c4a6ba3

Please sign in to comment.