@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | foreach ($package_extra as $name => $specs) { |
102 | 102 | |
103 | - if ( array_key_exists($name, $config) ) { |
|
103 | + if (array_key_exists($name, $config)) { |
|
104 | 104 | $io->write("<error>Duplicate task found!</error>"); |
105 | 105 | $io->write("<error>----------------------------</error>"); |
106 | 106 | $io->write("<error>Task $name in $package_name is already provided by ".$config[$name]["package_name"]."</error>"); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | |
111 | - if ( !self::validate($specs) ) { |
|
111 | + if (!self::validate($specs)) { |
|
112 | 112 | $io->write("<error>Invalid task definition in $package_name</error>"); |
113 | 113 | $io->write("<error>----------------------------</error>"); |
114 | 114 | $io->write("<error>$name => ".var_export($specs, true)."</error>"); |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | |
135 | 135 | $exists = array_key_exists($name, $config); |
136 | 136 | |
137 | - if ( $exists && $config[$name]["package_name"] == $package_name) { |
|
137 | + if ($exists && $config[$name]["package_name"] == $package_name) { |
|
138 | 138 | unset($config[$name]); |
139 | 139 | $io->write(" <info>-</info> Task [$name] removed"); |
140 | - } else if ( $exists ) { |
|
140 | + } else if ($exists) { |
|
141 | 141 | $io->write("<error>Task [$name] does not belong to $package_name and cannot be removed</error>"); |
142 | 142 | $io->write("<error>----------------------------</error>"); |
143 | 143 | $io->write("<error>Found existing task $name that belongs to ".$config[$name]["package_name"]); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | foreach ($package_extra as $plugin) { |
121 | 121 | |
122 | - if ( !self::validate($plugin) ) { |
|
122 | + if (!self::validate($plugin)) { |
|
123 | 123 | $io->write("<error>Invalid plugin definition in $package_name</error>"); |
124 | 124 | $io->write("<error>----------------------------</error>"); |
125 | 125 | $io->write("<error>".var_export($plugin, true)."</error>"); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | protected static function validate(array $extra) { |
150 | - return !( empty($extra["class"]) || empty($extra["event"]) ); |
|
150 | + return !(empty($extra["class"]) || empty($extra["event"])); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | } |
@@ -122,7 +122,7 @@ |
||
122 | 122 | |
123 | 123 | foreach ($package_extra as $command) { |
124 | 124 | |
125 | - if ( !self::validate($command) ) { |
|
125 | + if (!self::validate($command)) { |
|
126 | 126 | $io->write("<error>Invalid command definition in $package_name</error>"); |
127 | 127 | $io->write("<error>----------------------------</error>"); |
128 | 128 | $io->write("<error>".var_export($command, true)."</error>"); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | foreach ($package_extra as $route => $specs) { |
118 | 118 | |
119 | - if ( array_key_exists($route, $config) ) { |
|
119 | + if (array_key_exists($route, $config)) { |
|
120 | 120 | $io->write("<error>Duplicate route found!</error>"); |
121 | 121 | $io->write("<error>----------------------------</error>"); |
122 | 122 | $io->write("<error>Route $route in $package_name is already provided by ".$config[$route]["package_name"]."</error>"); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | |
127 | - if ( !self::validate($specs) ) { |
|
127 | + if (!self::validate($specs)) { |
|
128 | 128 | $io->write("<error>Invalid route definition in $package_name</error>"); |
129 | 129 | $io->write("<error>----------------------------</error>"); |
130 | 130 | $io->write("<error>$route => ".var_export($specs, true)."</error>"); |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | |
151 | 151 | $exists = array_key_exists($route, $config); |
152 | 152 | |
153 | - if ( $exists && $config[$route]["package_name"] == $package_name) { |
|
153 | + if ($exists && $config[$route]["package_name"] == $package_name) { |
|
154 | 154 | unset($config[$route]); |
155 | 155 | $io->write(" <info>-</info> route [$route] removed"); |
156 | - } else if ( $exists ) { |
|
156 | + } else if ($exists) { |
|
157 | 157 | $io->write("<error>Route [$route] does not belong to $package_name and cannot be removed</error>"); |
158 | 158 | $io->write("<error>----------------------------</error>"); |
159 | 159 | $io->write("<error>Found existing route $route that belongs to ".$config[$route]["package_name"]); |
@@ -34,15 +34,15 @@ |
||
34 | 34 | protected $comodojo_configuration_persistence; |
35 | 35 | |
36 | 36 | /** |
37 | - * {@inheritDoc} |
|
38 | - */ |
|
37 | + * {@inheritDoc} |
|
38 | + */ |
|
39 | 39 | public function deactivate(Composer $composer, IOInterface $io){ |
40 | 40 | |
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | - * {@inheritDoc} |
|
45 | - */ |
|
44 | + * {@inheritDoc} |
|
45 | + */ |
|
46 | 46 | public function uninstall(Composer $composer, IOInterface $io){ |
47 | 47 | |
48 | 48 | } |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * {@inheritDoc} |
38 | 38 | */ |
39 | - public function deactivate(Composer $composer, IOInterface $io){ |
|
39 | + public function deactivate(Composer $composer, IOInterface $io) { |
|
40 | 40 | |
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * {@inheritDoc} |
45 | 45 | */ |
46 | - public function uninstall(Composer $composer, IOInterface $io){ |
|
46 | + public function uninstall(Composer $composer, IOInterface $io) { |
|
47 | 47 | |
48 | 48 | } |
49 | 49 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $io = $event->getIO(); |
84 | 84 | |
85 | 85 | // If a script is in queue, start it now |
86 | - if ( $script !== null ) { |
|
86 | + if ($script !== null) { |
|
87 | 87 | $io->write("<info>Starting post-install-script</info>"); |
88 | 88 | $post_install_script = new $script($io, $configuration); |
89 | 89 | $io->write("<info>Post-install-script ends</info>"); |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | |
101 | 101 | // check if "real" configuration object is already in, and eventually load it |
102 | 102 | $configuration = $this->comodojo_configuration_persistence->load(); |
103 | - if ( !empty($configuration) ) { |
|
103 | + if (!empty($configuration)) { |
|
104 | 104 | $io->write('<comment>Global configuration object found ad loaded</comment>'); |
105 | 105 | return new Configuration($configuration); |
106 | 106 | } |
107 | 107 | |
108 | 108 | // if not, load it from root composer.json |
109 | 109 | $field = $this->installer_configuration->getGlobalConfig()->getExtraField(); |
110 | - if ( isset($extra[$field]) && is_array($extra[$field]) ) { |
|
110 | + if (isset($extra[$field]) && is_array($extra[$field])) { |
|
111 | 111 | $io->write('<comment>Global configuration retrieved from composer.json</comment>'); |
112 | 112 | $configuration = new Configuration($extra[$field]); |
113 | 113 | // overwrite base-path with real one |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | |
30 | 30 | $name = $this->getParameters()->get('config-file'); |
31 | 31 | |
32 | - if ( $name === null ) throw new InstallerException("No config-file name specified"); |
|
32 | + if ($name === null) throw new InstallerException("No config-file name specified"); |
|
33 | 33 | |
34 | - if ( file_exists($name) && is_readable($name) ) return json_decode(file_get_contents($name), true); |
|
34 | + if (file_exists($name) && is_readable($name)) return json_decode(file_get_contents($name), true); |
|
35 | 35 | |
36 | 36 | return []; |
37 | 37 | |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | |
45 | 45 | $name = $this->getParameters()->get('config-file'); |
46 | 46 | |
47 | - if ( $name === null ) throw new InstallerException("No config-file name specified"); |
|
47 | + if ($name === null) throw new InstallerException("No config-file name specified"); |
|
48 | 48 | |
49 | 49 | $filedata = json_encode($data); |
50 | 50 | |
51 | 51 | if ( |
52 | - ( file_exists($name) && is_writable($name) ) || |
|
52 | + (file_exists($name) && is_writable($name)) || |
|
53 | 53 | is_writeable(pathinfo($name, PATHINFO_DIRNAME)) |
54 | 54 | ) return file_put_contents($name, $filedata, LOCK_EX); |
55 | 55 |
@@ -29,9 +29,13 @@ discard block |
||
29 | 29 | |
30 | 30 | $name = $this->getParameters()->get('config-file'); |
31 | 31 | |
32 | - if ( $name === null ) throw new InstallerException("No config-file name specified"); |
|
32 | + if ( $name === null ) { |
|
33 | + throw new InstallerException("No config-file name specified"); |
|
34 | + } |
|
33 | 35 | |
34 | - if ( file_exists($name) && is_readable($name) ) return json_decode(file_get_contents($name), true); |
|
36 | + if ( file_exists($name) && is_readable($name) ) { |
|
37 | + return json_decode(file_get_contents($name), true); |
|
38 | + } |
|
35 | 39 | |
36 | 40 | return []; |
37 | 41 | |
@@ -44,14 +48,18 @@ discard block |
||
44 | 48 | |
45 | 49 | $name = $this->getParameters()->get('config-file'); |
46 | 50 | |
47 | - if ( $name === null ) throw new InstallerException("No config-file name specified"); |
|
51 | + if ( $name === null ) { |
|
52 | + throw new InstallerException("No config-file name specified"); |
|
53 | + } |
|
48 | 54 | |
49 | 55 | $filedata = json_encode($data); |
50 | 56 | |
51 | 57 | if ( |
52 | 58 | ( file_exists($name) && is_writable($name) ) || |
53 | 59 | is_writeable(pathinfo($name, PATHINFO_DIRNAME)) |
54 | - ) return file_put_contents($name, $filedata, LOCK_EX); |
|
60 | + ) { |
|
61 | + return file_put_contents($name, $filedata, LOCK_EX); |
|
62 | + } |
|
55 | 63 | |
56 | 64 | throw new InstallerException("Cannot write to configuration file $name"); |
57 | 65 |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | |
40 | 40 | $name = $this->getParameters()->get('config-file'); |
41 | 41 | |
42 | - if ( $name === null ) throw new InstallerException("No config-file name specified"); |
|
42 | + if ($name === null) throw new InstallerException("No config-file name specified"); |
|
43 | 43 | |
44 | - if ( file_exists($name) && is_readable($name) ) return Yaml::parse(file_get_contents($name)); |
|
44 | + if (file_exists($name) && is_readable($name)) return Yaml::parse(file_get_contents($name)); |
|
45 | 45 | |
46 | 46 | return []; |
47 | 47 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | $name = $this->getParameters()->get('config-file'); |
56 | 56 | |
57 | - if ( $name === null ) throw new InstallerException("No config-file name specified"); |
|
57 | + if ($name === null) throw new InstallerException("No config-file name specified"); |
|
58 | 58 | |
59 | 59 | $config_depth = $this->getParameters()->get('depth'); |
60 | 60 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $filedata = Yaml::dump($data, $depth); |
64 | 64 | |
65 | 65 | if ( |
66 | - ( file_exists($name) && is_writable($name) ) || |
|
66 | + (file_exists($name) && is_writable($name)) || |
|
67 | 67 | is_writeable(pathinfo($name, PATHINFO_DIRNAME)) |
68 | 68 | ) return file_put_contents($name, $filedata, LOCK_EX); |
69 | 69 |
@@ -39,9 +39,13 @@ discard block |
||
39 | 39 | |
40 | 40 | $name = $this->getParameters()->get('config-file'); |
41 | 41 | |
42 | - if ( $name === null ) throw new InstallerException("No config-file name specified"); |
|
42 | + if ( $name === null ) { |
|
43 | + throw new InstallerException("No config-file name specified"); |
|
44 | + } |
|
43 | 45 | |
44 | - if ( file_exists($name) && is_readable($name) ) return Yaml::parse(file_get_contents($name)); |
|
46 | + if ( file_exists($name) && is_readable($name) ) { |
|
47 | + return Yaml::parse(file_get_contents($name)); |
|
48 | + } |
|
45 | 49 | |
46 | 50 | return []; |
47 | 51 | |
@@ -54,7 +58,9 @@ discard block |
||
54 | 58 | |
55 | 59 | $name = $this->getParameters()->get('config-file'); |
56 | 60 | |
57 | - if ( $name === null ) throw new InstallerException("No config-file name specified"); |
|
61 | + if ( $name === null ) { |
|
62 | + throw new InstallerException("No config-file name specified"); |
|
63 | + } |
|
58 | 64 | |
59 | 65 | $config_depth = $this->getParameters()->get('depth'); |
60 | 66 | |
@@ -65,7 +71,9 @@ discard block |
||
65 | 71 | if ( |
66 | 72 | ( file_exists($name) && is_writable($name) ) || |
67 | 73 | is_writeable(pathinfo($name, PATHINFO_DIRNAME)) |
68 | - ) return file_put_contents($name, $filedata, LOCK_EX); |
|
74 | + ) { |
|
75 | + return file_put_contents($name, $filedata, LOCK_EX); |
|
76 | + } |
|
69 | 77 | |
70 | 78 | throw new InstallerException("Cannot write to configuration file $name"); |
71 | 79 |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | |
47 | 47 | public function __construct($name, array $content) { |
48 | 48 | |
49 | - if ( empty($content['driver']) ) throw new InstallerException("Missing driver for field $name"); |
|
50 | - if ( empty($content['persistence']) ) throw new InstallerException("Missing persistence for field $name"); |
|
49 | + if (empty($content['driver'])) throw new InstallerException("Missing driver for field $name"); |
|
50 | + if (empty($content['persistence'])) throw new InstallerException("Missing persistence for field $name"); |
|
51 | 51 | |
52 | 52 | $this->properties = [ |
53 | 53 | "driver" => $content['driver'], |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | "persistence-source" => null |
57 | 57 | ]; |
58 | 58 | |
59 | - if ( !empty($content['driver-source']) ) $this->properties['driver-source'] = $content['driver-source']; |
|
60 | - if ( !empty($content['persistence-source']) ) $this->properties['persistence-source'] = $content['persistence-source']; |
|
59 | + if (!empty($content['driver-source'])) $this->properties['driver-source'] = $content['driver-source']; |
|
60 | + if (!empty($content['persistence-source'])) $this->properties['persistence-source'] = $content['persistence-source']; |
|
61 | 61 | |
62 | - $parameters = isset($content['params']) && is_array($content['params']) ? $content['params'] : [] ; |
|
62 | + $parameters = isset($content['params']) && is_array($content['params']) ? $content['params'] : []; |
|
63 | 63 | |
64 | 64 | $this->parameters = new InstallerParameters($parameters); |
65 | 65 |
@@ -46,8 +46,12 @@ discard block |
||
46 | 46 | |
47 | 47 | public function __construct($name, array $content) { |
48 | 48 | |
49 | - if ( empty($content['driver']) ) throw new InstallerException("Missing driver for field $name"); |
|
50 | - if ( empty($content['persistence']) ) throw new InstallerException("Missing persistence for field $name"); |
|
49 | + if ( empty($content['driver']) ) { |
|
50 | + throw new InstallerException("Missing driver for field $name"); |
|
51 | + } |
|
52 | + if ( empty($content['persistence']) ) { |
|
53 | + throw new InstallerException("Missing persistence for field $name"); |
|
54 | + } |
|
51 | 55 | |
52 | 56 | $this->properties = [ |
53 | 57 | "driver" => $content['driver'], |
@@ -56,8 +60,12 @@ discard block |
||
56 | 60 | "persistence-source" => null |
57 | 61 | ]; |
58 | 62 | |
59 | - if ( !empty($content['driver-source']) ) $this->properties['driver-source'] = $content['driver-source']; |
|
60 | - if ( !empty($content['persistence-source']) ) $this->properties['persistence-source'] = $content['persistence-source']; |
|
63 | + if ( !empty($content['driver-source']) ) { |
|
64 | + $this->properties['driver-source'] = $content['driver-source']; |
|
65 | + } |
|
66 | + if ( !empty($content['persistence-source']) ) { |
|
67 | + $this->properties['persistence-source'] = $content['persistence-source']; |
|
68 | + } |
|
61 | 69 | |
62 | 70 | $parameters = isset($content['params']) && is_array($content['params']) ? $content['params'] : [] ; |
63 | 71 |
@@ -42,12 +42,12 @@ |
||
42 | 42 | $parameters = $extra->getParams(); |
43 | 43 | $base_path = realpath($composer->getConfig()->get('vendor-dir').'/../'); |
44 | 44 | |
45 | - if ( !class_exists($persistence) && $persistence_source !== null ) { |
|
45 | + if (!class_exists($persistence) && $persistence_source !== null) { |
|
46 | 46 | include $base_path."/$persistence_source"; |
47 | 47 | } |
48 | 48 | $this->persistence = new $persistence($composer, $io, $configuration, $parameters); |
49 | 49 | |
50 | - if ( !class_exists($driver) && $driver_source !== null ) { |
|
50 | + if (!class_exists($driver) && $driver_source !== null) { |
|
51 | 51 | include $base_path."/$driver_source"; |
52 | 52 | } |
53 | 53 | $this->driver = new $driver($composer, $io, $configuration, $parameters, $this->persistence); |