-
Notifications
You must be signed in to change notification settings - Fork 4
/
plugin_creator.sh
60 lines (48 loc) · 1.33 KB
/
plugin_creator.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Get name of plugin as an argument or prompt user for it
PLUGIN="$1"
while [ "$PLUGIN" == "" ] || [ -e "plugins/$PLUGIN" ]; do
read -p "Enter plugin name: " PLUGIN
done
# Create folder structure of the plugin
echo -n "> Creating plugin structure for $PLUGIN..."
mkdir -p plugins/$PLUGIN/{controllers,models,views,language}
# Create empty necessary files (touch wouldn't work for me)
for i in controller model plugin; do
echo "" > plugins/$PLUGIN/${PLUGIN}_${i}.php
done
# Empty config file
touch plugins/$PLUGIN/config.json
# Skeleton config file
echo "{
"version": "0.0.1",
"name": "",
"description": "",
"authors": [
{
"name" : "",
"url": ""
}
]
}
" > plugins/$PLUGIN/config.json
# Base plugin class that gets loaded into Blesta
echo "<?php
class ${PLUGIN}Plugin extends Plugin {
public function __construct(){
\$this->loadConfig(dirname(__FILE__) . DS . \"config.json\");
}
}
?>" > plugins/$PLUGIN/${PLUGIN}_plugin.php
# Controller plugin class that handles rendering files and displaying it to the user
echo "<?php
class ${PLUGIN}Controller extends AppController {
public function preAction(){
parent::preAction();
\$this->view->view = \"default\";
\$this->structure->view = \"default\";
}
}
?>" > plugins/$PLUGIN/${PLUGIN}_controller.php
echo "done."
exit 0