Passed
Push — develop ( c22bc5...6872a8 )
by Jens
02:24
created
src/storage/storage/FilesStorage.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -10,6 +10,10 @@
 block discarded – undo
10 10
 {
11 11
     protected $filesDir;
12 12
 
13
+    /**
14
+     * @param \CloudControl\Cms\storage\Repository $repository
15
+     * @param string $filesDir
16
+     */
13 17
     public function __construct($repository, $filesDir)
14 18
     {
15 19
         parent::__construct($repository);
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@  discard block
 block discarded – undo
8 8
 
9 9
 class FilesStorage extends AbstractStorage
10 10
 {
11
-    protected $filesDir;
11
+	protected $filesDir;
12 12
 
13
-    public function __construct($repository, $filesDir)
14
-    {
15
-        parent::__construct($repository);
16
-        $this->filesDir = $filesDir;
17
-    }
13
+	public function __construct($repository, $filesDir)
14
+	{
15
+		parent::__construct($repository);
16
+		$this->filesDir = $filesDir;
17
+	}
18 18
 
19 19
 
20
-    /**
20
+	/**
21 21
 	 * @return array
22 22
 	 */
23 23
 	public function getFiles() {
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 		return strcmp($a->file, $b->file);
112 112
 	}
113 113
 
114
-    protected function getDestinationPath()
115
-    {
116
-        $destinationPath = realpath($this->filesDir . DIRECTORY_SEPARATOR);
117
-        return $destinationPath;
118
-    }
114
+	protected function getDestinationPath()
115
+	{
116
+		$destinationPath = realpath($this->filesDir . DIRECTORY_SEPARATOR);
117
+		return $destinationPath;
118
+	}
119 119
 }
120 120
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 		$destinationPath = $this->getDestinationPath();
38 38
 
39 39
 		$filename = $this->validateFilename($postValues['name'], $destinationPath);
40
-		$destination = $destinationPath . '/' . $filename;
40
+		$destination = $destinationPath.'/'.$filename;
41 41
 
42 42
 		if ($postValues['error'] != '0') {
43
-			throw new \Exception('Error uploading file. Error code: ' . $postValues['error']);
43
+			throw new \Exception('Error uploading file. Error code: '.$postValues['error']);
44 44
 		}
45 45
 
46 46
 		if (move_uploaded_file($postValues['tmp_name'], $destination)) {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	public function deleteFileByName($filename)
84 84
 	{
85 85
 		$destinationPath = $this->getDestinationPath();
86
-		$destination = $destinationPath . '/' . $filename;
86
+		$destination = $destinationPath.'/'.$filename;
87 87
 
88 88
 		if (file_exists($destination)) {
89 89
 			$files = $this->getFiles();
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
     protected function getDestinationPath()
115 115
     {
116
-        $destinationPath = realpath($this->filesDir . DIRECTORY_SEPARATOR);
116
+        $destinationPath = realpath($this->filesDir.DIRECTORY_SEPARATOR);
117 117
         return $destinationPath;
118 118
     }
119 119
 }
120 120
\ No newline at end of file
Please login to merge, or discard this patch.
src/CloudControl.php 2 patches
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -11,129 +11,129 @@
 block discarded – undo
11 11
 
12 12
 class CloudControl
13 13
 {
14
-    public static function run()
15
-    {
16
-        new Application();
17
-    }
18
-
19
-    public static function postInstall(Event $event)
20
-    {
21
-        $event->getIO()->write("Post install");
22
-        self::checkInstall($event);
23
-    }
24
-
25
-    public static function postUpdate(Event $event)
26
-    {
27
-        $event->getIO()->write("Post update");
28
-        self::checkInstall($event);
29
-    }
30
-
31
-    /**
32
-     * @param Event $event
33
-     */
34
-    private static function checkInstall(Event $event)
35
-    {
36
-        $event->getIO()->write("*** Checking installation of Cloud Control framework ***");
37
-
38
-        $vendorDir = $event->getComposer()->getConfig()->get('vendor-dir');
39
-        $rootDir = realpath($vendorDir . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
40
-
41
-        $baseConfigTargetPath = $rootDir . DIRECTORY_SEPARATOR . 'config.json';
42
-        $configObject = self::getConfig($baseConfigTargetPath);
43
-
44
-        $configObject->{'vendorDir'} = realpath($vendorDir);
45
-        $configObject->{'rootDir'} = $rootDir;
46
-        $configObject->{'templateDir'} = self::createDir($event, $rootDir, 'templates');
47
-        $configObject->{'storageDir'} = self::createDir($event, $rootDir, $configObject->{'storageDir'});
48
-        $configObject->{'publicDir'} = self::createDir($event, $rootDir, 'public');
49
-        $configObject->{'jsDir'} = self::createDir($event, $configObject->{'publicDir'}, 'js');
50
-        $configObject->{'cssDir'} = self::createDir($event, $configObject->{'publicDir'}, 'css');
51
-        $configObject->{'imagesDir'} = self::createDir($event, $configObject->{'publicDir'}, 'images');
52
-        $configObject->{'filesDir'} = self::createDir($event, $configObject->{'publicDir'}, 'files');
53
-
54
-        $baseStorageDefaultPath = __DIR__ . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . '_storage.json';
55
-        $baseStorageSqlPath = __DIR__ . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . '_storage.sql';
56
-
57
-        self::createStorage($configObject->{'storageDir'}, $baseStorageDefaultPath, $baseStorageSqlPath);
58
-        self::saveConfig($event, $baseConfigTargetPath, $configObject);
59
-        self::copyInstallFile($event, 'public.htaccess', $configObject->{'publicDir'}, '.htaccess');
60
-        self::copyInstallFile($event, 'root.htaccess', $configObject->{'rootDir'}, '.htaccess');
61
-        self::copyInstallFile($event, 'base.php', $configObject->{'templateDir'});
62
-        self::copyInstallFile($event, 'cms.css', $configObject->{'cssDir'});
63
-        self::copyInstallFile($event, 'cms.js', $configObject->{'jsDir'});
64
-        self::copyInstallFile($event, 'index.php', $configObject->{'publicDir'});
65
-    }
66
-
67
-    /**
68
-     * @param Event $event
69
-     * @param $baseConfigTargetPath
70
-     * @param $configObject
71
-     * @internal param $rootDir
72
-     * @internal param $vendorDir
73
-     * @internal param $templateDir
74
-     * @internal param $storageDir
75
-     * @internal param $baseConfigDefaultPath
76
-     * @internal param $baseConfigTargetPath
77
-     * @internal param $storageDir
78
-     */
79
-    private static function saveConfig(Event $event, $baseConfigTargetPath, $configObject)
80
-    {
81
-        file_put_contents($baseConfigTargetPath, json_encode($configObject));
82
-        $event->getIO()->write("Saved config to: " . $baseConfigTargetPath);
83
-    }
84
-
85
-    private static function copyInstallFile(Event $event, $sourceFileName, $destinationPath, $destinationFileName = null)
86
-    {
87
-        $sourceFilePath = realpath(__DIR__ . DIRECTORY_SEPARATOR . 'install/_' . $sourceFileName);
88
-
89
-        if (file_exists($sourceFilePath) && realpath($destinationPath) !== false) {
90
-            if ($destinationFileName !== null) {
91
-                copy($sourceFilePath, realpath($destinationPath) . DIRECTORY_SEPARATOR . $destinationFileName);
92
-            } else {
93
-                copy($sourceFilePath, realpath($destinationPath) . DIRECTORY_SEPARATOR . $sourceFileName);
94
-            }
95
-
96
-            $event->getIO()->write("Copied file: " . $sourceFileName . ' to ' . $destinationPath);
97
-        } else {
98
-            $event->getIO()->write("[ERROR] Couldnt copy file: " . $sourceFileName . ' to ' . $destinationPath);
99
-        }
100
-    }
101
-
102
-    /**
103
-     * @param $storageDir
104
-     * @param $baseStorageDefaultPath
105
-     * @param $baseStorageSqlPath
106
-     */
107
-    private static function createStorage($storageDir, $baseStorageDefaultPath, $baseStorageSqlPath)
108
-    {
109
-        $repository = new Repository($storageDir);
110
-        $repository->init($baseStorageDefaultPath, $baseStorageSqlPath);
111
-    }
112
-
113
-    private static function createDir(Event $event, $rootDir, $dirName)
114
-    {
115
-        $dir = $rootDir . DIRECTORY_SEPARATOR . $dirName . DIRECTORY_SEPARATOR;
116
-        if (!is_dir($dir)) {
117
-            mkdir($dir);
118
-            $event->getIO()->write("Created dir: " . $dir);
119
-        }
120
-        return realpath($dir);
121
-    }
122
-
123
-    /**
124
-     * @param $configTargetPath
125
-     * @return mixed
126
-     */
127
-    private static function getConfig($configTargetPath)
128
-    {
129
-        $baseConfigDefaultPath = realpath(__DIR__ . DIRECTORY_SEPARATOR . 'install/_config.json');
130
-
131
-        if (file_exists($configTargetPath)) {
132
-            $config = json_decode(file_get_contents($configTargetPath));
133
-        } else {
134
-            $config = json_decode(file_get_contents($baseConfigDefaultPath));
135
-        }
136
-        return $config;
137
-    }
14
+	public static function run()
15
+	{
16
+		new Application();
17
+	}
18
+
19
+	public static function postInstall(Event $event)
20
+	{
21
+		$event->getIO()->write("Post install");
22
+		self::checkInstall($event);
23
+	}
24
+
25
+	public static function postUpdate(Event $event)
26
+	{
27
+		$event->getIO()->write("Post update");
28
+		self::checkInstall($event);
29
+	}
30
+
31
+	/**
32
+	 * @param Event $event
33
+	 */
34
+	private static function checkInstall(Event $event)
35
+	{
36
+		$event->getIO()->write("*** Checking installation of Cloud Control framework ***");
37
+
38
+		$vendorDir = $event->getComposer()->getConfig()->get('vendor-dir');
39
+		$rootDir = realpath($vendorDir . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
40
+
41
+		$baseConfigTargetPath = $rootDir . DIRECTORY_SEPARATOR . 'config.json';
42
+		$configObject = self::getConfig($baseConfigTargetPath);
43
+
44
+		$configObject->{'vendorDir'} = realpath($vendorDir);
45
+		$configObject->{'rootDir'} = $rootDir;
46
+		$configObject->{'templateDir'} = self::createDir($event, $rootDir, 'templates');
47
+		$configObject->{'storageDir'} = self::createDir($event, $rootDir, $configObject->{'storageDir'});
48
+		$configObject->{'publicDir'} = self::createDir($event, $rootDir, 'public');
49
+		$configObject->{'jsDir'} = self::createDir($event, $configObject->{'publicDir'}, 'js');
50
+		$configObject->{'cssDir'} = self::createDir($event, $configObject->{'publicDir'}, 'css');
51
+		$configObject->{'imagesDir'} = self::createDir($event, $configObject->{'publicDir'}, 'images');
52
+		$configObject->{'filesDir'} = self::createDir($event, $configObject->{'publicDir'}, 'files');
53
+
54
+		$baseStorageDefaultPath = __DIR__ . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . '_storage.json';
55
+		$baseStorageSqlPath = __DIR__ . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . '_storage.sql';
56
+
57
+		self::createStorage($configObject->{'storageDir'}, $baseStorageDefaultPath, $baseStorageSqlPath);
58
+		self::saveConfig($event, $baseConfigTargetPath, $configObject);
59
+		self::copyInstallFile($event, 'public.htaccess', $configObject->{'publicDir'}, '.htaccess');
60
+		self::copyInstallFile($event, 'root.htaccess', $configObject->{'rootDir'}, '.htaccess');
61
+		self::copyInstallFile($event, 'base.php', $configObject->{'templateDir'});
62
+		self::copyInstallFile($event, 'cms.css', $configObject->{'cssDir'});
63
+		self::copyInstallFile($event, 'cms.js', $configObject->{'jsDir'});
64
+		self::copyInstallFile($event, 'index.php', $configObject->{'publicDir'});
65
+	}
66
+
67
+	/**
68
+	 * @param Event $event
69
+	 * @param $baseConfigTargetPath
70
+	 * @param $configObject
71
+	 * @internal param $rootDir
72
+	 * @internal param $vendorDir
73
+	 * @internal param $templateDir
74
+	 * @internal param $storageDir
75
+	 * @internal param $baseConfigDefaultPath
76
+	 * @internal param $baseConfigTargetPath
77
+	 * @internal param $storageDir
78
+	 */
79
+	private static function saveConfig(Event $event, $baseConfigTargetPath, $configObject)
80
+	{
81
+		file_put_contents($baseConfigTargetPath, json_encode($configObject));
82
+		$event->getIO()->write("Saved config to: " . $baseConfigTargetPath);
83
+	}
84
+
85
+	private static function copyInstallFile(Event $event, $sourceFileName, $destinationPath, $destinationFileName = null)
86
+	{
87
+		$sourceFilePath = realpath(__DIR__ . DIRECTORY_SEPARATOR . 'install/_' . $sourceFileName);
88
+
89
+		if (file_exists($sourceFilePath) && realpath($destinationPath) !== false) {
90
+			if ($destinationFileName !== null) {
91
+				copy($sourceFilePath, realpath($destinationPath) . DIRECTORY_SEPARATOR . $destinationFileName);
92
+			} else {
93
+				copy($sourceFilePath, realpath($destinationPath) . DIRECTORY_SEPARATOR . $sourceFileName);
94
+			}
95
+
96
+			$event->getIO()->write("Copied file: " . $sourceFileName . ' to ' . $destinationPath);
97
+		} else {
98
+			$event->getIO()->write("[ERROR] Couldnt copy file: " . $sourceFileName . ' to ' . $destinationPath);
99
+		}
100
+	}
101
+
102
+	/**
103
+	 * @param $storageDir
104
+	 * @param $baseStorageDefaultPath
105
+	 * @param $baseStorageSqlPath
106
+	 */
107
+	private static function createStorage($storageDir, $baseStorageDefaultPath, $baseStorageSqlPath)
108
+	{
109
+		$repository = new Repository($storageDir);
110
+		$repository->init($baseStorageDefaultPath, $baseStorageSqlPath);
111
+	}
112
+
113
+	private static function createDir(Event $event, $rootDir, $dirName)
114
+	{
115
+		$dir = $rootDir . DIRECTORY_SEPARATOR . $dirName . DIRECTORY_SEPARATOR;
116
+		if (!is_dir($dir)) {
117
+			mkdir($dir);
118
+			$event->getIO()->write("Created dir: " . $dir);
119
+		}
120
+		return realpath($dir);
121
+	}
122
+
123
+	/**
124
+	 * @param $configTargetPath
125
+	 * @return mixed
126
+	 */
127
+	private static function getConfig($configTargetPath)
128
+	{
129
+		$baseConfigDefaultPath = realpath(__DIR__ . DIRECTORY_SEPARATOR . 'install/_config.json');
130
+
131
+		if (file_exists($configTargetPath)) {
132
+			$config = json_decode(file_get_contents($configTargetPath));
133
+		} else {
134
+			$config = json_decode(file_get_contents($baseConfigDefaultPath));
135
+		}
136
+		return $config;
137
+	}
138 138
 
139 139
 }
140 140
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
         $event->getIO()->write("*** Checking installation of Cloud Control framework ***");
37 37
 
38 38
         $vendorDir = $event->getComposer()->getConfig()->get('vendor-dir');
39
-        $rootDir = realpath($vendorDir . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
39
+        $rootDir = realpath($vendorDir.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR);
40 40
 
41
-        $baseConfigTargetPath = $rootDir . DIRECTORY_SEPARATOR . 'config.json';
41
+        $baseConfigTargetPath = $rootDir.DIRECTORY_SEPARATOR.'config.json';
42 42
         $configObject = self::getConfig($baseConfigTargetPath);
43 43
 
44 44
         $configObject->{'vendorDir'} = realpath($vendorDir);
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
         $configObject->{'imagesDir'} = self::createDir($event, $configObject->{'publicDir'}, 'images');
52 52
         $configObject->{'filesDir'} = self::createDir($event, $configObject->{'publicDir'}, 'files');
53 53
 
54
-        $baseStorageDefaultPath = __DIR__ . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . '_storage.json';
55
-        $baseStorageSqlPath = __DIR__ . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . '_storage.sql';
54
+        $baseStorageDefaultPath = __DIR__.DIRECTORY_SEPARATOR.'install'.DIRECTORY_SEPARATOR.'_storage.json';
55
+        $baseStorageSqlPath = __DIR__.DIRECTORY_SEPARATOR.'install'.DIRECTORY_SEPARATOR.'_storage.sql';
56 56
 
57 57
         self::createStorage($configObject->{'storageDir'}, $baseStorageDefaultPath, $baseStorageSqlPath);
58 58
         self::saveConfig($event, $baseConfigTargetPath, $configObject);
@@ -79,23 +79,23 @@  discard block
 block discarded – undo
79 79
     private static function saveConfig(Event $event, $baseConfigTargetPath, $configObject)
80 80
     {
81 81
         file_put_contents($baseConfigTargetPath, json_encode($configObject));
82
-        $event->getIO()->write("Saved config to: " . $baseConfigTargetPath);
82
+        $event->getIO()->write("Saved config to: ".$baseConfigTargetPath);
83 83
     }
84 84
 
85 85
     private static function copyInstallFile(Event $event, $sourceFileName, $destinationPath, $destinationFileName = null)
86 86
     {
87
-        $sourceFilePath = realpath(__DIR__ . DIRECTORY_SEPARATOR . 'install/_' . $sourceFileName);
87
+        $sourceFilePath = realpath(__DIR__.DIRECTORY_SEPARATOR.'install/_'.$sourceFileName);
88 88
 
89 89
         if (file_exists($sourceFilePath) && realpath($destinationPath) !== false) {
90 90
             if ($destinationFileName !== null) {
91
-                copy($sourceFilePath, realpath($destinationPath) . DIRECTORY_SEPARATOR . $destinationFileName);
91
+                copy($sourceFilePath, realpath($destinationPath).DIRECTORY_SEPARATOR.$destinationFileName);
92 92
             } else {
93
-                copy($sourceFilePath, realpath($destinationPath) . DIRECTORY_SEPARATOR . $sourceFileName);
93
+                copy($sourceFilePath, realpath($destinationPath).DIRECTORY_SEPARATOR.$sourceFileName);
94 94
             }
95 95
 
96
-            $event->getIO()->write("Copied file: " . $sourceFileName . ' to ' . $destinationPath);
96
+            $event->getIO()->write("Copied file: ".$sourceFileName.' to '.$destinationPath);
97 97
         } else {
98
-            $event->getIO()->write("[ERROR] Couldnt copy file: " . $sourceFileName . ' to ' . $destinationPath);
98
+            $event->getIO()->write("[ERROR] Couldnt copy file: ".$sourceFileName.' to '.$destinationPath);
99 99
         }
100 100
     }
101 101
 
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 
113 113
     private static function createDir(Event $event, $rootDir, $dirName)
114 114
     {
115
-        $dir = $rootDir . DIRECTORY_SEPARATOR . $dirName . DIRECTORY_SEPARATOR;
115
+        $dir = $rootDir.DIRECTORY_SEPARATOR.$dirName.DIRECTORY_SEPARATOR;
116 116
         if (!is_dir($dir)) {
117 117
             mkdir($dir);
118
-            $event->getIO()->write("Created dir: " . $dir);
118
+            $event->getIO()->write("Created dir: ".$dir);
119 119
         }
120 120
         return realpath($dir);
121 121
     }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     private static function getConfig($configTargetPath)
128 128
     {
129
-        $baseConfigDefaultPath = realpath(__DIR__ . DIRECTORY_SEPARATOR . 'install/_config.json');
129
+        $baseConfigDefaultPath = realpath(__DIR__.DIRECTORY_SEPARATOR.'install/_config.json');
130 130
 
131 131
         if (file_exists($configTargetPath)) {
132 132
             $config = json_decode(file_get_contents($configTargetPath));
Please login to merge, or discard this patch.