@@ -72,16 +72,16 @@ discard block |
||
| 72 | 72 | { |
| 73 | 73 | try { |
| 74 | 74 | ob_start(); |
| 75 | - $exectimeStart = microtime(true); |
|
| 75 | + $exectimeStart = microtime( true ); |
|
| 76 | 76 | |
| 77 | 77 | self::execute(); |
| 78 | 78 | |
| 79 | - $this->output->writeln(ob_get_clean()); |
|
| 80 | - $this->output->writeln(sprintf('Setup process lasted %1$f sec', (microtime(true) - $exectimeStart))); |
|
| 81 | - } catch(\Throwable $t) { |
|
| 82 | - $this->output->writeln(ob_get_clean()); |
|
| 83 | - $this->output->writeln($t->getMessage()); |
|
| 84 | - $this->output->writeln($t->getTraceAsString()); |
|
| 79 | + $this->output->writeln( ob_get_clean() ); |
|
| 80 | + $this->output->writeln( sprintf( 'Setup process lasted %1$f sec', ( microtime( true ) - $exectimeStart ) ) ); |
|
| 81 | + } catch( \Throwable $t ) { |
|
| 82 | + $this->output->writeln( ob_get_clean() ); |
|
| 83 | + $this->output->writeln( $t->getMessage() ); |
|
| 84 | + $this->output->writeln( $t->getTraceAsString() ); |
|
| 85 | 85 | |
| 86 | 86 | return false; |
| 87 | 87 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @param OutputInterface $output |
| 108 | 108 | */ |
| 109 | - public function setOutput(OutputInterface $output) : void |
|
| 109 | + public function setOutput( OutputInterface $output ) : void |
|
| 110 | 110 | { |
| 111 | 111 | $this->output = $output; |
| 112 | 112 | } |
@@ -128,30 +128,30 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public static function execute() |
| 130 | 130 | { |
| 131 | - ini_set('max_execution_time', 0); |
|
| 131 | + ini_set( 'max_execution_time', 0 ); |
|
| 132 | 132 | |
| 133 | - $objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); |
|
| 134 | - $extconf = $objectManager->get('TYPO3\CMS\Core\Configuration\ExtensionConfiguration'); |
|
| 135 | - $demo = $extconf->get('aimeos', 'useDemoData'); |
|
| 133 | + $objectManager = GeneralUtility::makeInstance( \TYPO3\CMS\Extbase\Object\ObjectManager::class ); |
|
| 134 | + $extconf = $objectManager->get( 'TYPO3\CMS\Core\Configuration\ExtensionConfiguration' ); |
|
| 135 | + $demo = $extconf->get( 'aimeos', 'useDemoData' ); |
|
| 136 | 136 | |
| 137 | - \Aimeos\MShop::cache(false); |
|
| 138 | - \Aimeos\MAdmin::cache(false); |
|
| 137 | + \Aimeos\MShop::cache( false ); |
|
| 138 | + \Aimeos\MAdmin::cache( false ); |
|
| 139 | 139 | |
| 140 | - $site = $extconf->get('siteCode', 'default'); |
|
| 141 | - $template = $extconf->get('siteTpl', 'default'); |
|
| 142 | - $codelen = $extconf->get('codeLength', 64); |
|
| 140 | + $site = $extconf->get( 'siteCode', 'default' ); |
|
| 141 | + $template = $extconf->get( 'siteTpl', 'default' ); |
|
| 142 | + $codelen = $extconf->get( 'codeLength', 64 ); |
|
| 143 | 143 | |
| 144 | 144 | $boostrap = \Aimeos\Aimeos\Base::aimeos(); |
| 145 | - $ctx = self::context(['setup' => ['default' => ['demo' => (string) $demo]]])->setEditor('setup'); |
|
| 145 | + $ctx = self::context( ['setup' => ['default' => ['demo' => (string) $demo]]] )->setEditor( 'setup' ); |
|
| 146 | 146 | |
| 147 | - \Aimeos\Setup::use($boostrap, ['codelength' => $codelen])->verbose('vvv') |
|
| 148 | - ->context($ctx->setEditor('aimeos:setup')) |
|
| 149 | - ->up($site, $template); |
|
| 147 | + \Aimeos\Setup::use( $boostrap, ['codelength' => $codelen] )->verbose( 'vvv' ) |
|
| 148 | + ->context( $ctx->setEditor( 'aimeos:setup' ) ) |
|
| 149 | + ->up( $site, $template ); |
|
| 150 | 150 | |
| 151 | - if (defined('TYPO3_version') && version_compare(constant('TYPO3_version'), '11.0.0', '<')) { |
|
| 152 | - $extconf->set('aimeos', 'useDemoData', ''); |
|
| 151 | + if( defined( 'TYPO3_version' ) && version_compare( constant( 'TYPO3_version' ), '11.0.0', '<' ) ) { |
|
| 152 | + $extconf->set( 'aimeos', 'useDemoData', '' ); |
|
| 153 | 153 | } else { |
| 154 | - $extconf->set('aimeos', ['useDemoData' => '']); |
|
| 154 | + $extconf->set( 'aimeos', ['useDemoData' => ''] ); |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | |
@@ -162,45 +162,45 @@ discard block |
||
| 162 | 162 | * @param array $list List of SQL statements |
| 163 | 163 | * @return array SQL statements required for the install tool |
| 164 | 164 | */ |
| 165 | - public static function schema(array $list) : array |
|
| 165 | + public static function schema( array $list ) : array |
|
| 166 | 166 | { |
| 167 | 167 | $ctx = self::context(); |
| 168 | - $connectionNames = array_keys($ctx->config()->get( 'resource')); |
|
| 169 | - $connectionNames = array_filter($connectionNames, fn (string $key): bool => str_starts_with($key, 'db')); |
|
| 168 | + $connectionNames = array_keys( $ctx->config()->get( 'resource' ) ); |
|
| 169 | + $connectionNames = array_filter( $connectionNames, fn ( string $key ): bool => str_starts_with( $key, 'db' ) ); |
|
| 170 | 170 | |
| 171 | - foreach ($connectionNames as $connectionName) { |
|
| 172 | - $conn = $ctx->db($connectionName); |
|
| 173 | - $adapter = $ctx->config('resource/' . $connectionName . '/adapter'); |
|
| 171 | + foreach( $connectionNames as $connectionName ) { |
|
| 172 | + $conn = $ctx->db( $connectionName ); |
|
| 173 | + $adapter = $ctx->config( 'resource/' . $connectionName . '/adapter' ); |
|
| 174 | 174 | |
| 175 | 175 | $tables = []; |
| 176 | - foreach(['fe_users_', 'madmin_', 'mshop_'] as $prefix) { |
|
| 177 | - switch ($adapter) { |
|
| 176 | + foreach( ['fe_users_', 'madmin_', 'mshop_'] as $prefix ) { |
|
| 177 | + switch( $adapter ) { |
|
| 178 | 178 | case "pgsql": $sql = 'SELECT tablename FROM pg_catalog.pg_tables where tablename ~ \'^' . $prefix . '\''; break; |
| 179 | 179 | default: $sql = 'SHOW TABLES like \'' . $prefix . '%\''; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - $result = $conn->create($sql)->execute(); |
|
| 182 | + $result = $conn->create( $sql )->execute(); |
|
| 183 | 183 | |
| 184 | - while(($row = $result->fetch(\Aimeos\Base\DB\Result\Base::FETCH_NUM)) !== null) { |
|
| 184 | + while( ( $row = $result->fetch( \Aimeos\Base\DB\Result\Base::FETCH_NUM ) ) !== null ) { |
|
| 185 | 185 | $tables[] = $row[0]; |
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - foreach($tables as $table) { |
|
| 190 | - switch ($adapter) { |
|
| 189 | + foreach( $tables as $table ) { |
|
| 190 | + switch( $adapter ) { |
|
| 191 | 191 | case "pgsql": $sql = 'CREATE TABLE IF NOT EXISTS ' . $table . '()'; break; |
| 192 | 192 | default: $sql = 'SHOW CREATE TABLE `' . $table . '`'; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - $result = $conn->create($sql)->execute(); |
|
| 195 | + $result = $conn->create( $sql )->execute(); |
|
| 196 | 196 | |
| 197 | - while(($row = $result->fetch(\Aimeos\Base\DB\Result\Base::FETCH_NUM)) !== null) { |
|
| 197 | + while( ( $row = $result->fetch( \Aimeos\Base\DB\Result\Base::FETCH_NUM ) ) !== null ) { |
|
| 198 | 198 | $str = $row[1]; |
| 199 | 199 | |
| 200 | - $str = str_replace('"', '`', $str); |
|
| 201 | - $str = preg_replace('/CONSTRAINT `[a-zA-Z0-9_-]+` /', '', $str); |
|
| 202 | - $str = preg_replace('/ DEFAULT CHARSET=[^ ;]+/', '', $str); |
|
| 203 | - $str = preg_replace('/ COLLATE=[^ ;]+/', '', $str); |
|
| 200 | + $str = str_replace( '"', '`', $str ); |
|
| 201 | + $str = preg_replace( '/CONSTRAINT `[a-zA-Z0-9_-]+` /', '', $str ); |
|
| 202 | + $str = preg_replace( '/ DEFAULT CHARSET=[^ ;]+/', '', $str ); |
|
| 203 | + $str = preg_replace( '/ COLLATE=[^ ;]+/', '', $str ); |
|
| 204 | 204 | |
| 205 | 205 | $list[] = $str . ";\n"; |
| 206 | 206 | } |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @param string|null $extname Installed extension name |
| 218 | 218 | */ |
| 219 | - public static function executeOnSignal(string $extname = null) |
|
| 219 | + public static function executeOnSignal( string $extname = null ) |
|
| 220 | 220 | { |
| 221 | - self::signal($extname); |
|
| 221 | + self::signal( $extname ); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | |
@@ -227,9 +227,9 @@ discard block |
||
| 227 | 227 | * |
| 228 | 228 | * @param string|null $extname Installed extension name |
| 229 | 229 | */ |
| 230 | - public static function signal(string $extname = null) |
|
| 230 | + public static function signal( string $extname = null ) |
|
| 231 | 231 | { |
| 232 | - if ($extname === 'aimeos' && \Aimeos\Aimeos\Base::getExtConfig('autoSetup', true)) { |
|
| 232 | + if( $extname === 'aimeos' && \Aimeos\Aimeos\Base::getExtConfig( 'autoSetup', true ) ) { |
|
| 233 | 233 | self::execute(); |
| 234 | 234 | } |
| 235 | 235 | } |
@@ -240,12 +240,12 @@ discard block |
||
| 240 | 240 | * |
| 241 | 241 | * @param AlterTableDefinitionStatementsEvent $event Event object |
| 242 | 242 | */ |
| 243 | - public function schemaEvent(AlterTableDefinitionStatementsEvent $event) |
|
| 243 | + public function schemaEvent( AlterTableDefinitionStatementsEvent $event ) |
|
| 244 | 244 | { |
| 245 | - $list = self::schema([]); |
|
| 245 | + $list = self::schema( [] ); |
|
| 246 | 246 | |
| 247 | - foreach ($list['sqlString'] ?? [] as $sql) { |
|
| 248 | - $event->addSqlData($sql); |
|
| 247 | + foreach( $list['sqlString'] ?? [] as $sql ) { |
|
| 248 | + $event->addSqlData( $sql ); |
|
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | |
@@ -255,9 +255,9 @@ discard block |
||
| 255 | 255 | * |
| 256 | 256 | * @param AfterPackageActivationEvent $event Event object |
| 257 | 257 | */ |
| 258 | - public function setupEvent(AfterPackageActivationEvent $event) |
|
| 258 | + public function setupEvent( AfterPackageActivationEvent $event ) |
|
| 259 | 259 | { |
| 260 | - if ($event->getPackageKey() === 'aimeos' && \Aimeos\Aimeos\Base::getExtConfig('autoSetup', true)) { |
|
| 260 | + if( $event->getPackageKey() === 'aimeos' && \Aimeos\Aimeos\Base::getExtConfig( 'autoSetup', true ) ) { |
|
| 261 | 261 | self::execute(); |
| 262 | 262 | } |
| 263 | 263 | } |
@@ -269,34 +269,34 @@ discard block |
||
| 269 | 269 | * @param array $config Nested array of configuration settings |
| 270 | 270 | * @return \Aimeos\MShop\ContextIface Context object |
| 271 | 271 | */ |
| 272 | - protected static function context(array $config = []) : \Aimeos\MShop\ContextIface |
|
| 272 | + protected static function context( array $config = [] ) : \Aimeos\MShop\ContextIface |
|
| 273 | 273 | { |
| 274 | - $aimeosExtPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('aimeos'); |
|
| 274 | + $aimeosExtPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath( 'aimeos' ); |
|
| 275 | 275 | |
| 276 | - if (file_exists($aimeosExtPath . '/Resources/Libraries/autoload.php') === true) { |
|
| 276 | + if( file_exists( $aimeosExtPath . '/Resources/Libraries/autoload.php' ) === true ) { |
|
| 277 | 277 | require_once $aimeosExtPath . '/Resources/Libraries/autoload.php'; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | $ctx = new \Aimeos\MShop\Context(); |
| 281 | - $conf = \Aimeos\Aimeos\Base::config($config); |
|
| 281 | + $conf = \Aimeos\Aimeos\Base::config( $config ); |
|
| 282 | 282 | |
| 283 | - $ctx->setConfig($conf); |
|
| 284 | - $ctx->setDatabaseManager(new \Aimeos\Base\DB\Manager\Standard($conf->get('resource', []), 'DBAL')); |
|
| 285 | - $ctx->setFilesystemManager(new \Aimeos\Base\Filesystem\Manager\Standard($conf->get('resource', []))); |
|
| 286 | - $ctx->setLogger(new \Aimeos\Base\Logger\Errorlog(\Aimeos\Base\Logger\Iface::INFO)); |
|
| 287 | - $ctx->setSession(new \Aimeos\Base\Session\None()); |
|
| 288 | - $ctx->setCache(new \Aimeos\Base\Cache\None()); |
|
| 283 | + $ctx->setConfig( $conf ); |
|
| 284 | + $ctx->setDatabaseManager( new \Aimeos\Base\DB\Manager\Standard( $conf->get( 'resource', [] ), 'DBAL' ) ); |
|
| 285 | + $ctx->setFilesystemManager( new \Aimeos\Base\Filesystem\Manager\Standard( $conf->get( 'resource', [] ) ) ); |
|
| 286 | + $ctx->setLogger( new \Aimeos\Base\Logger\Errorlog( \Aimeos\Base\Logger\Iface::INFO ) ); |
|
| 287 | + $ctx->setSession( new \Aimeos\Base\Session\None() ); |
|
| 288 | + $ctx->setCache( new \Aimeos\Base\Cache\None() ); |
|
| 289 | 289 | |
| 290 | 290 | // Reset before child processes are spawned to avoid lost DB connections afterwards (TYPO3 9.4 and above) |
| 291 | - if (php_sapi_name() === 'cli' && class_exists('\TYPO3\CMS\Core\Database\ConnectionPool') |
|
| 292 | - && method_exists('\TYPO3\CMS\Core\Database\ConnectionPool', 'resetConnections') |
|
| 291 | + if( php_sapi_name() === 'cli' && class_exists( '\TYPO3\CMS\Core\Database\ConnectionPool' ) |
|
| 292 | + && method_exists( '\TYPO3\CMS\Core\Database\ConnectionPool', 'resetConnections' ) |
|
| 293 | 293 | ) { |
| 294 | - $ctx->setProcess(new \Aimeos\Base\Process\Pcntl(\Aimeos\Aimeos\Base::getExtConfig('pcntlMax', 4))); |
|
| 294 | + $ctx->setProcess( new \Aimeos\Base\Process\Pcntl( \Aimeos\Aimeos\Base::getExtConfig( 'pcntlMax', 4 ) ) ); |
|
| 295 | 295 | } else { |
| 296 | - $ctx->setProcess(new \Aimeos\Base\Process\None()); |
|
| 296 | + $ctx->setProcess( new \Aimeos\Base\Process\None() ); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - $factory = GeneralUtility::makeInstance('TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory'); |
|
| 300 | - return $ctx->setPassword(new \Aimeos\Base\Password\Typo3($factory->getDefaultHashInstance('FE'))); |
|
| 299 | + $factory = GeneralUtility::makeInstance( 'TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory' ); |
|
| 300 | + return $ctx->setPassword( new \Aimeos\Base\Password\Typo3( $factory->getDefaultHashInstance( 'FE' ) ) ); |
|
| 301 | 301 | } |
| 302 | 302 | } |