Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite520d1e

Browse files
committed
feat: improve variable resolution and path prefixing
1 parentc387607 commite520d1e

File tree

7 files changed

+27
-42
lines changed

7 files changed

+27
-42
lines changed

‎context.yaml‎

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,44 +26,9 @@ documents:
2626
-'*Interface.php'
2727
showTreeView:true
2828

29-
-description:Project Templates
30-
outputPath:core/templates.md
31-
sources:
32-
-type:file
33-
sourcePaths:
34-
-src/Template
35-
-vendor/spiral/files/src/FilesInterface.php
36-
showTreeView:true
37-
38-
-description:Research Templates
39-
outputPath:core/drafling.md
40-
sources:
41-
-type:file
42-
sourcePaths:
43-
-src/Research/Config
44-
-src/Research/Domain
45-
-src/Research/Repository
46-
-src/Research/Service
47-
-src/Research/Storage/StorageDriverInterface.php
48-
49-
-description:Research FileStorage
50-
outputPath:drafling/file-storage.md
51-
sources:
52-
-type:file
53-
sourcePaths:
54-
-src/Research/Storage
55-
56-
-description:Research MCP
57-
outputPath:drafling/mcp.md
58-
sources:
59-
-type:file
60-
sourcePaths:
61-
-src/Research/MCP
62-
-src/McpServer/McpServerBootloader.php
63-
64-
6529
-description:"Changes in the Project"
6630
outputPath:"changes.md"
6731
sources:
6832
-type:git_diff
6933
commit:unstaged
34+

‎src/Config/Import/ImportResolver.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
useButschster\ContextGenerator\Config\Import\Merger\ConfigMergerProviderInterface;
1010
useButschster\ContextGenerator\Config\Import\PathPrefixer\DocumentOutputPathPrefixer;
1111
useButschster\ContextGenerator\Config\Import\PathPrefixer\SourcePathPrefixer;
12-
useButschster\ContextGenerator\Config\Import\Source\Config\SourceConfigInterface;
1312
useButschster\ContextGenerator\Config\Import\Source\Config\SourceConfigFactory;
13+
useButschster\ContextGenerator\Config\Import\Source\Config\SourceConfigInterface;
1414
useButschster\ContextGenerator\Config\Import\Source\Exception\ImportSourceException;
1515
useButschster\ContextGenerator\Config\Import\Source\ImportedConfig;
1616
useButschster\ContextGenerator\Config\Import\Source\ImportSourceProvider;
@@ -31,8 +31,8 @@ public function __construct(
3131
privateImportSourceProvider$sourceProvider,
3232
privateWildcardPathFinder$pathFinder,
3333
privateConfigMergerProviderInterface$configMergerProvider,
34-
privateDocumentOutputPathPrefixer$documentPrefixer =newDocumentOutputPathPrefixer(),
35-
privateSourcePathPrefixer$sourcePrefixer =newSourcePathPrefixer(),
34+
privateDocumentOutputPathPrefixer$documentPrefixer,
35+
privateSourcePathPrefixer$sourcePrefixer,
3636
privateSourceConfigFactory$sourceConfigFactory =newSourceConfigFactory(),
3737
privateCircularImportDetectorInterface$detector =newCircularImportDetector(),
3838
#[LoggerPrefix(prefix:'import-resolver')]

‎src/Config/Import/PathPrefixer/PathPrefixer.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44

55
namespaceButschster\ContextGenerator\Config\Import\PathPrefixer;
66

7+
useButschster\ContextGenerator\Lib\Variable\VariableResolver;
8+
79
/**
810
* Abstract base class for path prefix operations
911
*/
1012
abstractreadonlyclass PathPrefixer
1113
{
14+
publicfunction__construct(
15+
protectedVariableResolver$variables,
16+
) {}
17+
1218
/**
1319
* Apply a path prefix to the appropriate paths in a configuration
1420
*/
@@ -20,6 +26,7 @@ abstract public function applyPrefix(array $config, string $pathPrefix): array;
2026
protectedfunctioncombinePaths(string$prefix,string$path):string
2127
{
2228
$combined =\rtrim($prefix,'/') .'/' .\ltrim($path,'/');
29+
2330
return$this->normalizePath($combined);
2431
}
2532

‎src/Config/Import/PathPrefixer/SourcePathPrefixer.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,13 @@ private function applyPathPrefixToSource(array $source, string $prefix): array
5858
privatefunctionapplyPrefixToPaths(mixed$paths,string$prefix):mixed
5959
{
6060
if (\is_string($paths)) {
61+
$paths =$this->variables->resolve($paths);
62+
6163
// Skip absolute paths
6264
if ($this->isAbsolutePath($paths)) {
6365
return$paths;
6466
}
67+
6568
return$this->combinePaths($prefix,$paths);
6669
}
6770

‎src/Lib/Variable/Provider/PredefinedVariableProvider.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44

55
namespaceButschster\ContextGenerator\Lib\Variable\Provider;
66

7+
useButschster\ContextGenerator\DirectoriesInterface;
8+
79
/**
810
* Provider with predefined system variables
911
*/
1012
finalreadonlyclass PredefinedVariableProviderimplements VariableProviderInterface
1113
{
14+
publicfunction__construct(
15+
privateDirectoriesInterface$dirs,
16+
) {}
17+
1218
publicfunctionhas(string$name):bool
1319
{
1420
return\array_key_exists($name,$this->getPredefinedVariables());
@@ -37,6 +43,11 @@ private function getPredefinedVariables(): array
3743
'OS' =>PHP_OS,
3844
'HOSTNAME' =>\gethostname() ?:'unknown',
3945
'PWD' =>\getcwd() ?:'.',
46+
47+
'ROOT_PATH' => (string)$this->dirs->getRootPath(),
48+
'CONFIG_PATH' => (string)$this->dirs->getConfigPath(),
49+
'ENV_PATH' => (string)$this->dirs->getEnvFilePath(),
50+
'BINARY_PATH' => (string)$this->dirs->getBinaryPath(),
4051
];
4152
}
4253
}

‎src/Lib/Variable/VariableBootloader.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function defineSingletons(): array
4949
),
5050

5151
// Predefined system variables have lowest priority
52-
newPredefinedVariableProvider(),
52+
newPredefinedVariableProvider(dirs:$dirs),
5353
);
5454
},
5555

‎src/Lib/Variable/VariableReplacementProcessor.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespaceButschster\ContextGenerator\Lib\Variable;
66

77
useButschster\ContextGenerator\Application\Logger\LoggerPrefix;
8-
useButschster\ContextGenerator\Lib\Variable\Provider\PredefinedVariableProvider;
98
useButschster\ContextGenerator\Lib\Variable\Provider\VariableProviderInterface;
109
usePsr\Log\LoggerInterface;
1110

@@ -15,7 +14,7 @@
1514
finalreadonlyclass VariableReplacementProcessorimplements VariableReplacementProcessorInterface
1615
{
1716
publicfunction__construct(
18-
privateVariableProviderInterface$provider =newPredefinedVariableProvider(),
17+
privateVariableProviderInterface$provider,
1918
#[LoggerPrefix(prefix:'variable-replacement')]
2019
private ?LoggerInterface$logger =null,
2120
) {}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp