Browse code

Add a `PHPInstruction`

Manuel Thalmann authored on 24/04/2018 23:25:58
Showing 4 changed files
... ...
@@ -2,6 +2,8 @@
2 2
   - Beautify code using tslint
3 3
   - Add new Instruction-Types
4 4
     - SQL-Instruction
5
+    - PHPInstruction
6
+
5 7
 # WSCPackageGenerator v0.0.3
6 8
   - Fixed several templates which caused packages to not install such as:
7 9
     - The Package-metadata `package.xml`
8 10
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+import IFileInstruction from "./IFileInstruction";
2
+
3
+/**
4
+ * Represents an instruction which provides a php-script execute when invoking the instruction.
5
+ * 
6
+ * Please keep in mind to provide the file using a `FilesInstruction`.
7
+ */
8
+export default interface IPHPInstruction extends IFileInstruction
9
+{
10
+    /**
11
+     * Gets or sets the application attribute must have the same value as the application attribute
12
+     * of the file package installation plugin instruction so that
13
+     * the correct file in the intended application directory is executed.
14
+     */
15
+    Application?: string;
16
+}
0 17
\ No newline at end of file
1 18
new file mode 100644
... ...
@@ -0,0 +1,42 @@
1
+import FileInstruction from "./FileInstruction";
2
+import IFileInstruction from "./IFileInstruction";
3
+import IPHPInstruction from "./IPHPInstruction";
4
+import { isNullOrUndefined } from "util";
5
+
6
+/**
7
+ * Represents an instruction which provides a php-script execute when invoking the instruction.
8
+ * 
9
+ * Please keep in mind to provide the file using a `FilesInstruction`.
10
+ */
11
+export default class PHPInstruction extends FileInstruction implements IPHPInstruction
12
+{
13
+    /**
14
+     * The application attribute must have the same value as the application attribute
15
+     * of the file package installation plugin instruction so that
16
+     * the correct file in the intended application directory is executed.
17
+     */
18
+    public application: string; 
19
+
20
+    /**
21
+     * Initializes a new instance of the `PHPInstruction` class.
22
+     */
23
+    public constructor(options: IPHPInstruction)
24
+    {
25
+        super(options);
26
+
27
+        if (!isNullOrUndefined(options.Application))
28
+        {
29
+            this.application = options.Application;
30
+        }
31
+    }
32
+
33
+    public get Application(): string
34
+    {
35
+        return this.application;
36
+    }
37
+
38
+    public set Application(value: string)
39
+    {
40
+        this.application = value;
41
+    }
42
+}
0 43
\ No newline at end of file
... ...
@@ -15,6 +15,13 @@
15 15
         %><% case "SQLInstruction": %>
16 16
         <instruction type="sql"><%= instruction.FileName %></instruction><%
17 17
         %><% break; %><%
18
+        %><% case "PHPInstruction": %>
19
+        <instruction<% %> type="script"<%
20
+            %><% if (instruction.Application) { %><%
21
+                %> application="<%= instruction.Application %>"<%
22
+            %><% } %><%
23
+            %>><%= instruction.FileName %></instruction><%
24
+        %><% break; %><%
18 25
         %><% case "OptionsInstruction": %>
19 26
         <instruction type="option"><%= destination %><%= ComponentsPath %>/<%= instruction.FileName %></instruction>
20 27
         <instruction type="language"><%= destination %><%= ComponentsPath %>/<%= instruction.TranslationsDirectory %>/*.xml</instruction><%