Skip to content

Commit 6e85228

Browse files
authored
FRW-9645 Enable feature development. (#11264)
FRW-9645 Enable feature development.
1 parent 2123aa9 commit 6e85228

File tree

8 files changed

+93
-7
lines changed

8 files changed

+93
-7
lines changed

config/Shared/config_default.php

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
];
99
$config[KernelConstants::CORE_NAMESPACES] = [
1010
'SprykerShop',
11+
'SprykerFeature',
1112
'SprykerEco',
1213
'Spryker',
1314
'SprykerSdk',

src/Spryker/Zed/Development/Business/ArchitectureSniffer/AllModuleFinder.php

+16
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function find(): array
4949
$modules = [];
5050
$modules[] = $this->loadProjectModules();
5151
$modules[] = $this->loadCoreDevelopmentModules();
52+
$modules[] = $this->loadFeaturesDevelopmentModules();
5253
$modules[] = $this->loadOtherCoreModules();
5354

5455
return $this->addApplication(array_merge(...$modules));
@@ -87,6 +88,21 @@ protected function loadCoreDevelopmentModules(): array
8788
return array_merge(...$modules);
8889
}
8990

91+
/**
92+
* @return array
93+
*/
94+
protected function loadFeaturesDevelopmentModules(): array
95+
{
96+
$modules = [];
97+
98+
foreach (range('A', 'Z') as $letter) {
99+
$path = sprintf('%s/spryker/%s/Features/%s*/src/*/*', APPLICATION_VENDOR_DIR, 'spryker', $letter);
100+
$modules[] = $this->findModules($path, $this->developmentConfig->getSprykerFeatureNamespace());
101+
}
102+
103+
return array_merge(...$modules);
104+
}
105+
90106
/**
91107
* @return array
92108
*/

src/Spryker/Zed/Development/Business/Composer/ComposerJsonUpdater.php

+4
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ protected function getOrganizationFromComposerJsonFile(SplFileInfo $composerJson
209209
return $matches[1];
210210
}
211211

212+
if (preg_match('/vendor\/spryker\/spryker\/Features\/\w+\/composer.json$/', $realPath, $matches)) {
213+
return 'spryker-feature';
214+
}
215+
212216
if (preg_match('/vendor\/([a-z_-]+)\/[a-z_-]+\/composer.json$/', $realPath, $matches)) {
213217
return $matches[1];
214218
}

src/Spryker/Zed/Development/Business/Composer/Updater/AutoloadUpdater.php

+6
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ class AutoloadUpdater implements UpdaterInterface
104104
*/
105105
public const SPRYKER_NAMESPACE = 'Spryker';
106106

107+
/**
108+
* @var string
109+
*/
110+
public const SPRYKER_FEATURE_NAMESPACE = 'SprykerFeature';
111+
107112
/**
108113
* @var string
109114
*/
@@ -169,6 +174,7 @@ class AutoloadUpdater implements UpdaterInterface
169174
*/
170175
protected $autoloadPSR4Whitelist = [
171176
self::SPRYKER_NAMESPACE,
177+
self::SPRYKER_FEATURE_NAMESPACE,
172178
self::SPRYKER_SHOP_NAMESPACE,
173179
self::SPRYKER_ECO_NAMESPACE,
174180
self::BASE_HELPER_DIRECTORY,

src/Spryker/Zed/Development/Business/DevelopmentBusinessFactory.php

+12
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
use Spryker\Zed\Development\Business\Module\PathBuilder\PathBuilderComposite;
176176
use Spryker\Zed\Development\Business\Module\PathBuilder\PathBuilderInterface;
177177
use Spryker\Zed\Development\Business\Module\PathBuilder\SprykerEcoModulePathBuilder;
178+
use Spryker\Zed\Development\Business\Module\PathBuilder\SprykerFeatureModulePathBuilder;
178179
use Spryker\Zed\Development\Business\Module\PathBuilder\SprykerMerchantPortalModulePathBuilder;
179180
use Spryker\Zed\Development\Business\Module\PathBuilder\SprykerModulePathBuilder;
180181
use Spryker\Zed\Development\Business\Module\PathBuilder\SprykerSdkModulePathBuilder;
@@ -337,6 +338,7 @@ public function createPathBuilder(): PathBuilderInterface
337338
return new PathBuilderComposite([
338339
$this->createSprykerStandaloneModuleFilePathBuilder(),
339340
$this->createSprykerModuleFilePathBuilder(),
341+
$this->createSprykerFeatureModuleFilePathBuilder(),
340342
$this->createSprykerShopModuleFilePathBuilder(),
341343
$this->createSprykerEcoModuleFilePathBuilder(),
342344
$this->createSprykerSdkModulePathBuilder(),
@@ -362,6 +364,16 @@ public function createSprykerModuleFilePathBuilder(): PathBuilderInterface
362364
);
363365
}
364366

367+
/**
368+
* @return \Spryker\Zed\Development\Business\Module\PathBuilder\PathBuilderInterface
369+
*/
370+
public function createSprykerFeatureModuleFilePathBuilder(): PathBuilderInterface
371+
{
372+
return new SprykerFeatureModulePathBuilder(
373+
$this->getConfig(),
374+
);
375+
}
376+
365377
/**
366378
* @return \Spryker\Zed\Development\Business\Module\PathBuilder\PathBuilderInterface
367379
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/**
4+
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5+
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6+
*/
7+
8+
namespace Spryker\Zed\Development\Business\Module\PathBuilder;
9+
10+
class SprykerFeatureModulePathBuilder extends AbstractPathBuilder
11+
{
12+
/**
13+
* @var string
14+
*/
15+
protected const ORGANIZATION = 'SprykerFeature';
16+
}

src/Spryker/Zed/Development/Business/Propel/PropelAbstractClassValidator.php

+14-6
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ protected function validateModules(OutputInterface $output): bool
5757
protected function getModuleNames(): array
5858
{
5959
$finder = new Finder();
60-
$finder->directories()->in(APPLICATION_VENDOR_DIR . '/spryker/spryker/Bundles/')->depth('< 1');
60+
$finder->directories()->in([
61+
APPLICATION_VENDOR_DIR . '/spryker/spryker/Bundles/',
62+
APPLICATION_VENDOR_DIR . '/spryker/spryker/Features/',
63+
])->depth('< 1');
6164

6265
$modules = [];
6366

@@ -127,7 +130,10 @@ protected function getModuleSchemaFileFinder(string $module)
127130
*/
128131
protected function getPathToModuleSchemas(string $module): string
129132
{
130-
return sprintf('%1$s/spryker/spryker/Bundles/%2$s/src/Spryker/Zed/%2$s/Persistence/Propel/Schema/', APPLICATION_VENDOR_DIR, $module);
133+
$bundlePath = sprintf('%1$s/spryker/spryker/Bundles/%2$s/src/Spryker/Zed/%2$s/Persistence/Propel/Schema/', APPLICATION_VENDOR_DIR, $module);
134+
$featurePath = sprintf('%1$s/spryker/spryker/Features/%2$s/src/SprykerFeature/Zed/%2$s/Persistence/Propel/Schema/', APPLICATION_VENDOR_DIR, $module);
135+
136+
return is_dir($featurePath) ? $featurePath : $bundlePath;
131137
}
132138

133139
/**
@@ -195,16 +201,18 @@ protected function abstractClassesForTableExists(array $simpleXmlTableElements,
195201
$tableName = $this->getTableNameFromSimpleXmlTableElement($simpleXmlTableElement);
196202

197203
$abstractEntityClass = sprintf('Spryker\\Zed\\%s\\Persistence\\Propel\\Abstract%s', $module, $phpName);
198-
if (!class_exists($abstractEntityClass)) {
204+
$abstractFeatureEntityClass = sprintf('SprykerFeature\\Zed\\%s\\Persistence\\Propel\\Abstract%s', $module, $phpName);
205+
if (!class_exists($abstractEntityClass) && !class_exists($abstractFeatureEntityClass)) {
199206
$isValid = false;
200-
$output->writeln(sprintf('<fg=yellow>%s</> <fg=red>does not exists, please create one.</>', $abstractEntityClass));
207+
$output->writeln(sprintf('<fg=red>Neither %s nor %s</> <fg=red>does not exists, please create one.</>', $abstractEntityClass, $abstractFeatureEntityClass));
201208
$output->writeln(sprintf('<fg=green>vendor/bin/console spryk:run AddZedPersistencePropelAbstractEntity --module=\'%1$s\' --targetModule=\'%1$s\' --tableName=\'%2$s\' -n</>', $module, $tableName));
202209
}
203210

204211
$abstractQueryClass = sprintf('Spryker\\Zed\\%s\\Persistence\\Propel\\Abstract%sQuery', $module, $phpName);
205-
if (!class_exists($abstractQueryClass)) {
212+
$abstractFeatureQueryClass = sprintf('SprykerFeature\\Zed\\%s\\Persistence\\Propel\\Abstract%sQuery', $module, $phpName);
213+
if (!class_exists($abstractQueryClass) && !class_exists($abstractFeatureQueryClass)) {
206214
$isValid = false;
207-
$output->writeln(sprintf('<fg=red>%s does not exists, please create one.</>', $abstractQueryClass));
215+
$output->writeln(sprintf('<fg=red>Neither %s nor %s does not exists, please create one.</>', $abstractQueryClass, $abstractFeatureQueryClass));
208216
$output->writeln(sprintf('<fg=green>vendor/bin/console spryk:run AddZedPersistencePropelAbstractQuery --module=\'%1$s\' --targetModule=\'%1$s\' --tableName=\'%2$s\' -n</>', $module, $tableName));
209217
}
210218
}

src/Spryker/Zed/Development/DevelopmentConfig.php

+24-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class DevelopmentConfig extends AbstractBundleConfig
6060
*/
6161
protected const GROUP_SPRYKER_TEST = 'SprykerTest';
6262

63+
/**
64+
* @var string
65+
*/
66+
protected const NAMESPACE_SPRYKER_FEATURE = 'SprykerFeature';
67+
6368
/**
6469
* @var array<string>
6570
*/
@@ -96,6 +101,7 @@ class DevelopmentConfig extends AbstractBundleConfig
96101
*/
97102
protected const INTERNAL_NAMESPACES_LIST = [
98103
self::NAMESPACE_SPRYKER,
104+
self::NAMESPACE_SPRYKER_FEATURE,
99105
self::NAMESPACE_SPRYKER_SHOP,
100106
self::NAMESPACE_SPRYKER_MERCHANT_PORTAL,
101107
];
@@ -105,6 +111,7 @@ class DevelopmentConfig extends AbstractBundleConfig
105111
*/
106112
protected const INTERNAL_NAMESPACES_TO_PATH_MAPPING = [
107113
self::NAMESPACE_SPRYKER => APPLICATION_ROOT_DIR . DIRECTORY_SEPARATOR . 'vendor/spryker/',
114+
self::NAMESPACE_SPRYKER_FEATURE => APPLICATION_ROOT_DIR . DIRECTORY_SEPARATOR . 'vendor/spryker/',
108115
self::NAMESPACE_SPRYKER_SHOP => APPLICATION_ROOT_DIR . DIRECTORY_SEPARATOR . 'vendor/spryker-shop/',
109116
self::NAMESPACE_SPRYKER_ECO => APPLICATION_ROOT_DIR . DIRECTORY_SEPARATOR . 'vendor/spryker-eco/',
110117
self::NAMESPACE_SPRYKER_SDK => APPLICATION_ROOT_DIR . DIRECTORY_SEPARATOR . 'vendor/spryker-sdk/',
@@ -139,7 +146,7 @@ public function getPermissionMode(): int
139146
*/
140147
public function getInternalNamespaces(): array
141148
{
142-
return ['Spryker', 'SprykerEco', 'SprykerSdk', 'SprykerShop', 'Orm'];
149+
return ['Spryker', 'SprykerFeature', 'SprykerEco', 'SprykerSdk', 'SprykerShop', 'Orm'];
143150
}
144151

145152
/**
@@ -153,6 +160,8 @@ public function getTwigPathPatterns(): array
153160
$this->getPathToCore() . '%1$s/src/Spryker/Zed/%1$s/Presentation/',
154161
$this->getPathToCore() . '%1$s/src/Spryker/Yves/%1$s/Theme/',
155162
$this->getPathToShop() . '%1$s/src/SprykerShop/Yves/%1$s/Theme/',
163+
$this->getPathToCore() . '%1$s/src/SprykerFeature/Zed/%1$s/Presentation/',
164+
$this->getPathToCore() . '%1$s/src/SprykerFeature/Yves/%1$s/Theme/',
156165
];
157166
}
158167

@@ -276,6 +285,7 @@ public function getOrganizationPathMap(): array
276285
{
277286
return [
278287
'Spryker' => $this->getPathToCore(),
288+
'SprykerFeature' => $this->getPathToCore(),
279289
'SprykerEco' => $this->getPathToEco(),
280290
];
281291
}
@@ -890,4 +900,17 @@ public function isStandaloneMode(): bool
890900
{
891901
return (bool)getenv('DEVELOPMENT_STANDALONE_MODE');
892902
}
903+
904+
/**
905+
* Specification:
906+
* - Returns Spryker Feature namespace.
907+
*
908+
* @api
909+
*
910+
* @return string
911+
*/
912+
public function getSprykerFeatureNamespace(): string
913+
{
914+
return static::NAMESPACE_SPRYKER_FEATURE;
915+
}
893916
}

0 commit comments

Comments
 (0)