Skip to content

Commit b6dc18e

Browse files
Update how to get project types.
1 parent 53d2365 commit b6dc18e

File tree

11 files changed

+33
-23
lines changed

11 files changed

+33
-23
lines changed

files/default/inspectionProfiles/MediaCT.xml renamed to files/default/inspectionProfiles/Global.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<component name="InspectionProjectProfileManager">
22
<profile version="1.0">
3-
<option name="myName" value="Youwe" />
3+
<option name="myName" value="Global" />
44
<inspection_tool class="AmdModulesDependencies" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
55
<inspection_tool class="BadExpressionStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
66
<inspection_tool class="BladeControlDirectives" enabled="false" level="WARNING" enabled_by_default="false" />
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<component name="InspectionProjectProfileManager">
22
<settings>
3-
<option name="projectProfile" value="Youwe" />
4-
<option name="PROJECT_PROFILE" value="Youwe" />
3+
<option name="projectProfile" value="Global" />
4+
<option name="PROJECT_PROFILE" value="Global" />
55
<version value="1.0" />
66
</settings>
7-
</component>
7+
</component>

src/Patcher/CodeStylePatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function patch(
2828
$this->copyFile(
2929
$environment->getDefaultsFilesystem(),
3030
$environment->getIdeConfigFilesystem(),
31-
'codeStyleSettings.xml'
31+
'codeStyleSettings.xml'
3232
);
3333
}
3434
}

src/Patcher/CopyFilesTrait.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Youwe\CodingStandard\PhpStorm\Patcher;
1111

1212
use Youwe\CodingStandard\PhpStorm\FilesystemInterface;
13+
use Youwe\CodingStandard\PhpStorm\ProjectTypeResolver;
1314

1415
trait CopyFilesTrait
1516
{
@@ -19,15 +20,17 @@ trait CopyFilesTrait
1920
* @param FilesystemInterface $source
2021
* @param FilesystemInterface $destination
2122
* @param string $path
23+
* @param string $type
2224
*
2325
* @return void
2426
*/
2527
private function copyDirectory(
2628
FilesystemInterface $source,
2729
FilesystemInterface $destination,
28-
string $path
30+
string $path,
31+
string $type = ProjectTypeResolver::DEFAULT_PROJECT_TYPE
2932
): void {
30-
foreach ($source->listFiles($path) as $filePath) {
33+
foreach ($source->listFiles($type . DIRECTORY_SEPARATOR . $path) as $filePath) {
3134
$this->copyFile($source, $destination, $filePath);
3235
}
3336
}
@@ -38,17 +41,21 @@ private function copyDirectory(
3841
* @param FilesystemInterface $source
3942
* @param FilesystemInterface $destination
4043
* @param string $path
44+
* @param string $type
4145
*
4246
* @return void
4347
*/
4448
private function copyFile(
4549
FilesystemInterface $source,
4650
FilesystemInterface $destination,
47-
string $path
51+
string $path,
52+
string $type = ProjectTypeResolver::DEFAULT_PROJECT_TYPE
4853
): void {
54+
$projectPath = $type . DIRECTORY_SEPARATOR . $path;
55+
4956
$destination->put(
50-
$path,
51-
$source->read($path)
57+
$projectPath,
58+
$source->read($projectPath)
5259
);
5360
}
5461
}

src/Patcher/FileTemplatesPatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function patch(
4545
$this->copyDirectory(
4646
$environment->getDefaultsFilesystem(),
4747
$environment->getIdeConfigFilesystem(),
48-
'default/fileTemplates'
48+
'fileTemplates'
4949
);
5050

5151
$this->patchWorkspaceConfig(

src/Patcher/InspectionsPatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class InspectionsPatcher implements ConfigPatcherInterface
1818
use CopyFilesTrait;
1919

2020
public const PROJECT_PHPCS = 'phpcs.xml';
21-
public const INSPECTION_PROFILE = 'default/inspectionProfiles/Global.xml';
21+
public const INSPECTION_PROFILE = 'inspectionProfiles/Global.xml';
2222

2323
/**
2424
* @var XmlAccessorInterface

src/Patcher/Magento2/FileTemplatesPatcher.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public function patch(
3030
$this->copyDirectory(
3131
$environment->getDefaultsFilesystem(),
3232
$environment->getIdeConfigFilesystem(),
33-
$environment->getProjectTypeResolver()->resolve() . DIRECTORY_SEPARATOR . 'fileTemplates'
33+
DIRECTORY_SEPARATOR . 'fileTemplates',
34+
$environment->getProjectTypeResolver()->resolve()
3435
);
3536
}
3637
}

src/Patcher/Magento2/LiveTemplatesPatcher.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public function patch(
3232
$this->copyDirectory(
3333
$environment->getDefaultsFilesystem(),
3434
$environment->getIdeDefaultConfigFilesystem(),
35-
$environment->getProjectTypeResolver()->resolve() . DIRECTORY_SEPARATOR . 'templates'
35+
'templates',
36+
$environment->getProjectTypeResolver()->resolve()
3637
);
3738
}
3839
}

src/Patcher/Magento2/TemplateSettingsPatcher.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,13 @@ public function patch(
7171
public function patchFileTemplateSettings(
7272
EnvironmentInterface $environment
7373
): void {
74-
$path = $environment->getProjectTypeResolver()->resolve() . DIRECTORY_SEPARATOR . 'file.template.settings.xml';
74+
$path = 'file.template.settings.xml';
7575
if (!$environment->getIdeConfigFilesystem()->has($path)) {
7676
$this->copyFile(
7777
$environment->getDefaultsFilesystem(),
7878
$environment->getIdeConfigFilesystem(),
79-
$path
79+
$path,
80+
$environment->getProjectTypeResolver()->resolve()
8081
);
8182
} else {
8283
$xml = simplexml_load_string(

tests/Patcher/CodeStylePatcherTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public function testPatch()
3131
$ideConfigFs
3232
->expects($this->once())
3333
->method('put')
34-
->with('codeStyleSettings.xml', '<xml/>');
34+
->with('default/codeStyleSettings.xml', '<xml/>');
3535

3636
$defaultsFs = $this->createMock(FilesystemInterface::class);
3737
$defaultsFs
3838
->expects($this->once())
3939
->method('read')
40-
->with('codeStyleSettings.xml')
40+
->with('default/codeStyleSettings.xml')
4141
->willReturn('<xml/>');
4242

4343
$environment = $this->createConfiguredMock(

0 commit comments

Comments
 (0)