Skip to content

Commit fc3baf0

Browse files
authored
Merge pull request #122 from SysBind/v1.2.9
V1.2.9
2 parents 21e5360 + 139c76f commit fc3baf0

5 files changed

Lines changed: 41 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).
77

88
## [Unreleased]
99

10+
## [1.2.9]
11+
12+
### Added
13+
14+
- Auto complete to Database object dependency injection
15+
- Add Moodle directory to PHP include path
16+
1017
## [1.2.8] - 2024-08-14
1118

1219
### Changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pluginGroup = il.co.sysbind.moodledev
44
pluginName = moodle-dev
55
pluginRepositoryUrl = https://github.com/SysBind/moodle-dev
66
# SemVer format -> https://semver.org
7-
pluginVersion = 1.2.8
7+
pluginVersion = 1.2.9
88

99
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1010
pluginSinceBuild = 233
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
package il.co.sysbind.moodledev
22

3-
import com.intellij.AbstractBundle
3+
import com.intellij.DynamicBundle
44
import org.jetbrains.annotations.NonNls
55
import org.jetbrains.annotations.PropertyKey
66

77
@NonNls
88
private const val BUNDLE = "messages.MoodleBundle"
99

10-
object MoodleBundle : AbstractBundle(BUNDLE) {
10+
object MoodleBundle : DynamicBundle(BUNDLE) {
1111

12-
@Suppress("SpreadOperator")
1312
@JvmStatic
14-
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) = getMessage(key, *params)
13+
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
14+
getMessage(key, *params)
1515

16-
@Suppress("SpreadOperator")
16+
@Suppress("unused")
1717
@JvmStatic
18-
fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) = run {
19-
message(key, *params)
20-
}
18+
fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
19+
getLazyMessage(key, *params)
2120
}

src/main/kotlin/il/co/sysbind/moodledev/project/MoodleSettingsForm.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.intellij.openapi.project.guessProjectDir
88
import com.intellij.openapi.ui.TextFieldWithBrowseButton
99
import com.intellij.ui.components.JBCheckBox
1010
import com.intellij.ui.dsl.builder.*
11+
import com.jetbrains.php.config.library.PhpIncludePathManager
1112
import com.jetbrains.php.frameworks.PhpFrameworkConfigurable
1213
import com.jetbrains.php.lang.PhpLanguage
1314
import il.co.sysbind.moodledev.MoodleBundle
@@ -71,12 +72,32 @@ class MoodleSettingsForm(val project: Project) : PhpFrameworkConfigurable {
7172
} else {
7273
settings.moodlePath = project.guessProjectDir()?.path ?: ""
7374
}
75+
val moodlePathStr = settings.moodlePath
7476
if (isBeingUsed) {
7577
val codeStyleSettings = CodeStyle.getSettings(project)
7678
MoodlePhpPredefinedCodeStyle().apply(codeStyleSettings, PhpLanguage.INSTANCE)
7779
MoodleJavascriptPredefinedCodeStyle().apply(codeStyleSettings, JavascriptLanguage.INSTANCE)
7880
MoodleLessPredefinedCodeStyle().apply(codeStyleSettings, LESSLanguage.INSTANCE)
7981
MoodleScssPredefinedCodeStyle().apply(codeStyleSettings, SCSSLanguage.INSTANCE)
82+
if (settings.moodlePath.isNotBlank()) {
83+
// Get the PhpIncludePathManager for the current project
84+
val includePathManager = PhpIncludePathManager.getInstance(project)
85+
// Add the Moodle path to the PHP include paths
86+
val includePathList = includePathManager.includePath
87+
if (!includePathList.contains(moodlePathStr)) {
88+
includePathList.add(moodlePathStr)
89+
includePathManager.includePath = includePathList
90+
}
91+
}
92+
} else {
93+
if (moodlePathStr.isNotBlank() && moodlePathStr != project.guessProjectDir()?.path) {
94+
val includePathManager = PhpIncludePathManager.getInstance(project)
95+
val includePathList = includePathManager.includePath
96+
if (includePathList.contains(moodlePathStr)) {
97+
includePathList.remove(moodlePathStr)
98+
includePathManager.includePath = includePathList
99+
}
100+
}
80101
}
81102
}
82103

src/main/resources/liveTemplates/Moodle.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@
99
<option name="PHP" value="true" />
1010
</context>
1111
</template>
12+
<template name="didb" value="protected readonly \moodle_database $db," description="Use dependency injection of global $DB" toReformat="false" toShortenFQNames="true">
13+
<context>
14+
<option name="PHP" value="true" />
15+
</context>
16+
</template>
1217
</templateSet>

0 commit comments

Comments
 (0)