-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1670 from spryker-shop/feature/ae-147/master-feat…
…ure-module-ssp FRW-9645 nonsplit to split merge
- Loading branch information
Showing
8 changed files
with
179 additions
and
42 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...d/DocumentationGeneratorRestApi/Business/DocumentationGeneratorRestApiBusinessFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), | ||
); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
src/Pyz/Zed/DocumentationGeneratorRestApi/Business/Finder/GlueControllerFinder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |