@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | * @param Event $event Event instance |
29 | 29 | * @throws \RuntimeException If an error occured |
30 | 30 | */ |
31 | - public static function setupDatabase( Event $event ) |
|
31 | + public static function setupDatabase(Event $event) |
|
32 | 32 | { |
33 | 33 | $options = $env = array(); |
34 | 34 | |
35 | - if( $event->isDevMode() ) { |
|
35 | + if ($event->isDevMode()) { |
|
36 | 36 | $options[] = '--option=setup/default/demo:1'; |
37 | 37 | } else { |
38 | 38 | $env[] = '--env=prod'; |
39 | 39 | } |
40 | 40 | |
41 | - self::executeCommand( $event, 'aimeos:setup', $options + $env ); |
|
42 | - self::executeCommand( $event, 'aimeos:cache', $env ); |
|
41 | + self::executeCommand($event, 'aimeos:setup', $options + $env); |
|
42 | + self::executeCommand($event, 'aimeos:cache', $env); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -49,16 +49,16 @@ discard block |
||
49 | 49 | * @param Event $event Event instance |
50 | 50 | * @throws \RuntimeException If an error occured |
51 | 51 | */ |
52 | - public static function updateConfig( Event $event ) |
|
52 | + public static function updateConfig(Event $event) |
|
53 | 53 | { |
54 | - $event->getIO()->write( 'Ensure existing config and routing for the shop bundle' ); |
|
54 | + $event->getIO()->write('Ensure existing config and routing for the shop bundle'); |
|
55 | 55 | |
56 | - $options = self::getOptions( $event ); |
|
56 | + $options = self::getOptions($event); |
|
57 | 57 | |
58 | - if( isset( $options['symfony-app-dir'] ) ) |
|
58 | + if (isset($options['symfony-app-dir'])) |
|
59 | 59 | { |
60 | - self::updateConfigFile( $options['symfony-app-dir'] . '/config/config.yml' ); |
|
61 | - self::updateRoutingFile( $options['symfony-app-dir'] . '/config/routing.yml' ); |
|
60 | + self::updateConfigFile($options['symfony-app-dir'].'/config/config.yml'); |
|
61 | + self::updateRoutingFile($options['symfony-app-dir'].'/config/routing.yml'); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -69,26 +69,26 @@ discard block |
||
69 | 69 | * @param Event $event Event instance |
70 | 70 | * @throws \RuntimeException If an error occured |
71 | 71 | */ |
72 | - public static function installBundle( Event $event ) |
|
72 | + public static function installBundle(Event $event) |
|
73 | 73 | { |
74 | - $event->getIO()->write( 'Installing the Aimeos shop bundle' ); |
|
74 | + $event->getIO()->write('Installing the Aimeos shop bundle'); |
|
75 | 75 | |
76 | - $options = self::getOptions( $event ); |
|
76 | + $options = self::getOptions($event); |
|
77 | 77 | $securedir = 'var'; |
78 | 78 | |
79 | - if( isset( $options['symfony-app-dir'] ) && is_dir( $options['symfony-app-dir'] ) ) { |
|
79 | + if (isset($options['symfony-app-dir']) && is_dir($options['symfony-app-dir'])) { |
|
80 | 80 | $securedir = $options['symfony-app-dir']; |
81 | 81 | } |
82 | 82 | |
83 | - if( isset( $options['symfony-var-dir'] ) && is_dir( $options['symfony-var-dir'] ) ) { |
|
83 | + if (isset($options['symfony-var-dir']) && is_dir($options['symfony-var-dir'])) { |
|
84 | 84 | $securedir = $options['symfony-var-dir']; |
85 | 85 | } |
86 | 86 | |
87 | - $webdir = ( isset( $options['symfony-web-dir'] ) ? $options['symfony-web-dir'] : 'public' ); |
|
87 | + $webdir = (isset($options['symfony-web-dir']) ? $options['symfony-web-dir'] : 'public'); |
|
88 | 88 | |
89 | - self::createDirectory( $securedir . '/secure' ); |
|
90 | - self::createDirectory( $webdir . '/preview' ); |
|
91 | - self::createDirectory( $webdir . '/files' ); |
|
89 | + self::createDirectory($securedir.'/secure'); |
|
90 | + self::createDirectory($webdir.'/preview'); |
|
91 | + self::createDirectory($webdir.'/files'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -98,14 +98,14 @@ discard block |
||
98 | 98 | * @param string $dir Absolute path of the new directory |
99 | 99 | * @throws \RuntimeException If directory couldn't be created |
100 | 100 | */ |
101 | - protected static function createDirectory( $dir ) |
|
101 | + protected static function createDirectory($dir) |
|
102 | 102 | { |
103 | 103 | $perm = 0755; |
104 | 104 | |
105 | - if( !is_dir( $dir ) && !mkdir( $dir, $perm, true ) ) |
|
105 | + if (!is_dir($dir) && !mkdir($dir, $perm, true)) |
|
106 | 106 | { |
107 | 107 | $msg = 'Unable to create directory "%1$s" with permission "%2$s"'; |
108 | - throw new \RuntimeException( sprintf( $msg, $dir, $perm ) ); |
|
108 | + throw new \RuntimeException(sprintf($msg, $dir, $perm)); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
@@ -118,28 +118,28 @@ discard block |
||
118 | 118 | * @param array List of configuration options for the given command |
119 | 119 | * @throws \RuntimeException If the command couldn't be executed |
120 | 120 | */ |
121 | - protected static function executeCommand( Event $event, $cmd, array $options = array() ) |
|
121 | + protected static function executeCommand(Event $event, $cmd, array $options = array()) |
|
122 | 122 | { |
123 | - $php = escapeshellarg( self::getPhp() ); |
|
124 | - $console = escapeshellarg( self::getConsoleDir( $event ) . '/console' ); |
|
125 | - $cmd = escapeshellarg( $cmd ); |
|
123 | + $php = escapeshellarg(self::getPhp()); |
|
124 | + $console = escapeshellarg(self::getConsoleDir($event).'/console'); |
|
125 | + $cmd = escapeshellarg($cmd); |
|
126 | 126 | |
127 | - foreach( $options as $key => $option ) { |
|
128 | - $options[$key] = escapeshellarg( $option ); |
|
127 | + foreach ($options as $key => $option) { |
|
128 | + $options[$key] = escapeshellarg($option); |
|
129 | 129 | } |
130 | 130 | |
131 | - if( $event->getIO()->isDecorated() ) { |
|
131 | + if ($event->getIO()->isDecorated()) { |
|
132 | 132 | $console .= ' --ansi'; |
133 | 133 | } |
134 | 134 | |
135 | - $process = new Process( $php . ' ' . $console . ' ' . $cmd . ' ' . implode( ' ', $options ), null, null, null, 3600 ); |
|
135 | + $process = new Process($php.' '.$console.' '.$cmd.' '.implode(' ', $options), null, null, null, 3600); |
|
136 | 136 | |
137 | - $process->run( function( $type, $buffer ) use ( $event ) { |
|
138 | - $event->getIO()->write( $buffer, false ); |
|
137 | + $process->run(function($type, $buffer) use ($event) { |
|
138 | + $event->getIO()->write($buffer, false); |
|
139 | 139 | } ); |
140 | 140 | |
141 | - if( !$process->isSuccessful() ) { |
|
142 | - throw new \RuntimeException( sprintf( 'An error occurred when executing the "%s" command', escapeshellarg( $cmd ) ) ); |
|
141 | + if (!$process->isSuccessful()) { |
|
142 | + throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command', escapeshellarg($cmd))); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
@@ -152,17 +152,17 @@ discard block |
||
152 | 152 | * @return string The path to the console directory |
153 | 153 | * @throws \RuntimeException If console directory couldn't be found |
154 | 154 | */ |
155 | - protected static function getConsoleDir( Event $event ) |
|
155 | + protected static function getConsoleDir(Event $event) |
|
156 | 156 | { |
157 | - $options = self::getOptions( $event ); |
|
157 | + $options = self::getOptions($event); |
|
158 | 158 | |
159 | 159 | $bindir = 'bin'; |
160 | 160 | |
161 | - if( isset( $options['symfony-app-dir'] ) && is_dir( $options['symfony-app-dir'] ) ) { |
|
161 | + if (isset($options['symfony-app-dir']) && is_dir($options['symfony-app-dir'])) { |
|
162 | 162 | $bindir = $options['symfony-app-dir']; |
163 | 163 | } |
164 | 164 | |
165 | - if( isset( $options['symfony-bin-dir'] ) && is_dir( $options['symfony-bin-dir'] ) ) { |
|
165 | + if (isset($options['symfony-bin-dir']) && is_dir($options['symfony-bin-dir'])) { |
|
166 | 166 | $bindir = $options['symfony-bin-dir']; |
167 | 167 | } |
168 | 168 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @param Event $event Command event object |
177 | 177 | * @return array Associative list of option keys and values |
178 | 178 | */ |
179 | - protected static function getOptions( Event $event ) |
|
179 | + protected static function getOptions(Event $event) |
|
180 | 180 | { |
181 | 181 | return $event->getComposer()->getPackage()->getExtra(); |
182 | 182 | } |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | { |
193 | 193 | $phpFinder = new PhpExecutableFinder; |
194 | 194 | |
195 | - if( !( $phpPath = $phpFinder->find() ) ) { |
|
196 | - throw new \RuntimeException( 'The php executable could not be found, add it to your PATH environment variable and try again' ); |
|
195 | + if (!($phpPath = $phpFinder->find())) { |
|
196 | + throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again'); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | return $phpPath; |
@@ -206,15 +206,15 @@ discard block |
||
206 | 206 | * @param string $filename Name of the YAML config file |
207 | 207 | * @throws \RuntimeException If file is not found |
208 | 208 | */ |
209 | - protected static function updateConfigFile( $filename ) |
|
209 | + protected static function updateConfigFile($filename) |
|
210 | 210 | { |
211 | - if( ( $content = file_get_contents( $filename ) ) === false ) { |
|
212 | - throw new \RuntimeException( sprintf( 'File "%1$s" not found', $filename ) ); |
|
211 | + if (($content = file_get_contents($filename)) === false) { |
|
212 | + throw new \RuntimeException(sprintf('File "%1$s" not found', $filename)); |
|
213 | 213 | } |
214 | 214 | |
215 | - if( self::addAsseticBundle( $content ) === true ) { |
|
215 | + if (self::addAsseticBundle($content) === true) { |
|
216 | 216 | $fs = new Filesystem(); |
217 | - $fs->dumpFile( $filename, $content ); |
|
217 | + $fs->dumpFile($filename, $content); |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
@@ -225,29 +225,29 @@ discard block |
||
225 | 225 | * @param string $filename Name of the YAML config file |
226 | 226 | * @throws \RuntimeException If file is not found |
227 | 227 | */ |
228 | - protected static function updateRoutingFile( $filename ) |
|
228 | + protected static function updateRoutingFile($filename) |
|
229 | 229 | { |
230 | 230 | $content = ''; |
231 | 231 | |
232 | - if( file_exists( $filename ) && ( $content = file_get_contents( $filename ) ) === false ) { |
|
233 | - throw new \RuntimeException( sprintf( 'File "%1$s" not readable', $filename ) ); |
|
232 | + if (file_exists($filename) && ($content = file_get_contents($filename)) === false) { |
|
233 | + throw new \RuntimeException(sprintf('File "%1$s" not readable', $filename)); |
|
234 | 234 | } |
235 | 235 | |
236 | - if( strpos( $content, 'aimeos_shop:' ) === false ) |
|
236 | + if (strpos($content, 'aimeos_shop:') === false) |
|
237 | 237 | { |
238 | - $content .= "\n" . 'fos_user: |
|
238 | + $content .= "\n".'fos_user: |
|
239 | 239 | resource: "@FOSUserBundle/Resources/config/routing/all.xml"'; |
240 | 240 | } |
241 | 241 | |
242 | - if( strpos( $content, 'aimeos_shop:' ) === false ) |
|
242 | + if (strpos($content, 'aimeos_shop:') === false) |
|
243 | 243 | { |
244 | - $content .= "\n" . 'aimeos_shop: |
|
244 | + $content .= "\n".'aimeos_shop: |
|
245 | 245 | resource: "@AimeosShopBundle/Resources/config/routing.yml" |
246 | 246 | prefix: /'; |
247 | 247 | } |
248 | 248 | |
249 | 249 | $fs = new Filesystem(); |
250 | - $fs->dumpFile( $filename, $content ); |
|
250 | + $fs->dumpFile($filename, $content); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
@@ -257,14 +257,14 @@ discard block |
||
257 | 257 | * @param string &$content Content of the config.yml file |
258 | 258 | * @return boolean True if modified, false if not |
259 | 259 | */ |
260 | - protected static function addAsseticBundle( &$content ) |
|
260 | + protected static function addAsseticBundle(&$content) |
|
261 | 261 | { |
262 | - if( preg_match( "/ bundles:[ ]*\[.*'AimeosShopBundle'.*\]/", $content ) !== 1 ) |
|
262 | + if (preg_match("/ bundles:[ ]*\[.*'AimeosShopBundle'.*\]/", $content) !== 1) |
|
263 | 263 | { |
264 | - $search = array( "/ bundles:[ ]*\[([^\]]+)\]/", "/ bundles:[ ]*\[([ ]*)\]/" ); |
|
265 | - $replace = array( " bundles: [$1,'AimeosShopBundle']", " bundles: ['AimeosShopBundle']" ); |
|
264 | + $search = array("/ bundles:[ ]*\[([^\]]+)\]/", "/ bundles:[ ]*\[([ ]*)\]/"); |
|
265 | + $replace = array(" bundles: [$1,'AimeosShopBundle']", " bundles: ['AimeosShopBundle']"); |
|
266 | 266 | |
267 | - if( ( $content = preg_replace( $search, $replace, $content ) ) !== null ) { |
|
267 | + if (($content = preg_replace($search, $replace, $content)) !== null) { |
|
268 | 268 | return true; |
269 | 269 | } |
270 | 270 | } |