Skip to content

Commit

Permalink
#27952: missing store_name in GraphQL resolver - initDeclaredDependen…
Browse files Browse the repository at this point in the history
…cies() fix
  • Loading branch information
sasha19957099 committed Jun 24, 2020
1 parent 26df598 commit 0e32b44
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class DeclarativeSchemaDependencyProvider
*/
private $dependencyProvider;

/**
* DeclarativeSchemaDependencyProvider constructor.
* @param DependencyProvider $dependencyProvider
*/
public function __construct(DependencyProvider $dependencyProvider)
{
$this->dependencyProvider = $dependencyProvider;
Expand All @@ -68,7 +72,6 @@ public function __construct(DependencyProvider $dependencyProvider)
*/
public function getDeclaredExistingModuleDependencies(string $moduleName): array
{
$this->dependencyProvider->initDeclaredDependencies();
$dependencies = $this->getDependenciesFromFiles($this->getSchemaFileNameByModuleName($moduleName));
$dependencies = $this->filterSelfDependency($moduleName, $dependencies);
$declared = $this->dependencyProvider->getDeclaredDependencies(
Expand Down Expand Up @@ -103,7 +106,6 @@ public function getDeclaredExistingModuleDependencies(string $moduleName): array
*/
public function getUndeclaredModuleDependencies(string $moduleName): array
{
$this->dependencyProvider->initDeclaredDependencies();
$dependencies = $this->getDependenciesFromFiles($this->getSchemaFileNameByModuleName($moduleName));
$dependencies = $this->filterSelfDependency($moduleName, $dependencies);
return $this->collectDependencies($moduleName, $dependencies);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,13 @@ class DependencyProvider
private $packageModuleMapping = [];

/**
* Initialise map of dependencies.
*
* @throws \Magento\TestFramework\Inspection\Exception
* DependencyProvider constructor.
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\TestFramework\Inspection\Exception
*/
public function initDeclaredDependencies()
public function __construct()
{
if (empty($this->mapDependencies)) {
$jsonFiles = Files::init()->getComposerFiles(ComponentRegistrar::MODULE, false);
foreach ($jsonFiles as $file) {
$json = new \Magento\Framework\Config\Composer\Package($this->readJsonFile($file));
$moduleName = $this->convertModuleName($json->get('name'));
$require = array_keys((array)$json->get('require'));
$this->presetDependencies($moduleName, $require, self::TYPE_HARD);
}
}
$this->initDeclaredDependencies();
}

/**
Expand Down Expand Up @@ -86,6 +77,25 @@ public function getDeclaredDependencies(string $module, string $type, string $ma
return $this->mapDependencies[$module][$type][$mapType] ?? [];
}

/**
* Initialise map of dependencies.
*
* @throws \Magento\TestFramework\Inspection\Exception
* @throws \Magento\Framework\Exception\LocalizedException
*/
private function initDeclaredDependencies()
{
if (empty($this->mapDependencies)) {
$jsonFiles = Files::init()->getComposerFiles(ComponentRegistrar::MODULE, false);
foreach ($jsonFiles as $file) {
$json = new \Magento\Framework\Config\Composer\Package($this->readJsonFile($file));
$moduleName = $this->convertModuleName($json->get('name'));
$require = array_keys((array)$json->get('require'));
$this->presetDependencies($moduleName, $require, self::TYPE_HARD);
}
}
}

/**
* Add dependencies to dependency list.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function __construct(DependencyProvider $dependencyProvider)
*/
public function getDeclaredExistingModuleDependencies(string $moduleName): array
{
$this->dependencyProvider->initDeclaredDependencies();
$dependencies = $this->getDependenciesFromSchema($moduleName);
$declared = $this->dependencyProvider->getDeclaredDependencies(
$moduleName,
Expand All @@ -73,7 +72,6 @@ public function getDeclaredExistingModuleDependencies(string $moduleName): array
*/
public function getUndeclaredModuleDependencies(string $moduleName): array
{
$this->dependencyProvider->initDeclaredDependencies();
$dependencies = $this->getDependenciesFromSchema($moduleName);
return $this->collectDependencies($moduleName, $dependencies);
}
Expand Down

0 comments on commit 0e32b44

Please sign in to comment.