/** * @test */ public function subProcessCommandEvaluatesSubRequestIniEntriesCorrectly() { $settings = array('core' => array('context' => 'Testing', 'phpBinaryPathAndFilename' => '/must/be/set/according/to/schema', 'subRequestIniEntries' => array('someSetting' => 'withValue', 'someFlagSettingWithoutValue' => ''))); $actual = $this->scriptsMock->_call('buildSubprocessCommand', 'flow:foo:identifier', $settings); $this->assertContains(sprintf(' -d %s=%s ', escapeshellarg('someSetting'), escapeshellarg('withValue')), $actual); $this->assertContains(sprintf(' -d %s ', escapeshellarg('someFlagSettingWithoutValue')), $actual); }
/** * Run a standalone development server * * Starts an embedded server, see http://php.net/manual/en/features.commandline.webserver.php * Note: This requires PHP 5.4+ * * To change the context Flow will run in, you can set the <b>FLOW_CONTEXT</b> environment variable: * <i>export FLOW_CONTEXT=Development && ./flow server:run</i> * * @param string $host The host name or IP address for the server to listen on * @param integer $port The server port to listen on * @return void */ public function runCommand($host = '127.0.0.1', $port = 8081) { $command = Scripts::buildPhpCommand($this->settings); $address = sprintf('%s:%s', $host, $port); $command .= ' -S ' . escapeshellarg($address) . ' -t ' . escapeshellarg(FLOW_PATH_WEB) . ' ' . escapeshellarg(FLOW_PATH_FLOW . '/Scripts/PhpDevelopmentServerRouter.php'); $this->outputLine('Server running. Please go to <b>http://' . $address . '</b> to browse the application.'); exec($command); }
/** * Post composer install or update tasks * * @param \Composer\Script\CommandEvent $event */ public static function postUpdateAndInstall(CommandEvent $event) { $options = array(); if ($event->isDevMode()) { $options['options'] = 'setup/default/demo:1'; } \TYPO3\Flow\Core\Booting\Scripts::executeCommand('aimeos.shop:aimeos:setup', array(), true, $options); \TYPO3\Flow\Core\Booting\Scripts::executeCommand('aimeos.shop:aimeos:cache', array()); }
/** * Create a flow bootstrap instance */ protected function initializeFlow() { require_once __DIR__ . '/../../../../../../../Framework/TYPO3.Flow/Classes/TYPO3/Flow/Core/Bootstrap.php'; if (!defined('FLOW_PATH_ROOT')) { define('FLOW_PATH_ROOT', realpath(__DIR__ . '/../../../../../../../..') . '/'); } // The new classloader needs warnings converted to exceptions if (!defined('BEHAT_ERROR_REPORTING')) { define('BEHAT_ERROR_REPORTING', E_ALL); // Load ErrorException class, since it will be used in the Behat error handler class_exists('Behat\\Behat\\Exception\\ErrorException'); class_exists('Behat\\Testwork\\Call\\Exception\\CallErrorException'); } $bootstrap = new Bootstrap('Testing/Behat'); Scripts::initializeClassLoader($bootstrap); Scripts::initializeSignalSlot($bootstrap); Scripts::initializePackageManagement($bootstrap); $bootstrap->buildRuntimeSequence()->invoke($bootstrap); return $bootstrap; }
/** * Refreeze a package * * Refreezes a currently frozen package: all precompiled information is removed * and file monitoring will consider the package exactly once, on the next * request. After that request, the package remains frozen again, just with the * updated data. * * By specifying <b>all</b> as a package key, all currently frozen packages are * refrozen (the default). * * @param string $packageKey Key of the package to refreeze, or 'all' * @return void * @see typo3.flow:package:freeze * @see typo3.flow:cache:flush */ public function refreezeCommand($packageKey = 'all') { if (!$this->bootstrap->getContext()->isDevelopment()) { $this->outputLine('Package freezing is only supported in Development context.'); $this->quit(3); } $packagesToRefreeze = []; if ($packageKey === 'all') { foreach (array_keys($this->packageManager->getAvailablePackages()) as $packageKey) { if ($this->packageManager->isPackageFrozen($packageKey)) { $packagesToRefreeze[] = $packageKey; } } if ($packagesToRefreeze === []) { $this->outputLine('Nothing to do, no packages were frozen.'); $this->quit(0); } } else { if ($packageKey === null) { $this->outputLine('You must specify a package to refreeze.'); $this->quit(1); } if (!$this->packageManager->isPackageAvailable($packageKey)) { $this->outputLine('Package "%s" is not available.', [$packageKey]); $this->quit(2); } if (!$this->packageManager->isPackageFrozen($packageKey)) { $this->outputLine('Package "%s" was not frozen.', [$packageKey]); $this->quit(0); } $packagesToRefreeze = [$packageKey]; } foreach ($packagesToRefreeze as $packageKey) { $this->packageManager->refreezePackage($packageKey); $this->outputLine('Refroze package "%s".', [$packageKey]); } Scripts::executeCommand('typo3.flow:cache:flush', $this->settings, false); $this->sendAndExit(0); }
/** * This method is called when the form of this step has been submitted * * @param array $formValues * @return void * @throws \Exception */ public function postProcessFormValues(array $formValues) { $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'TYPO3.Flow.persistence.backendOptions.driver', $formValues['driver']); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'TYPO3.Flow.persistence.backendOptions.dbname', $formValues['dbname']); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'TYPO3.Flow.persistence.backendOptions.user', $formValues['user']); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'TYPO3.Flow.persistence.backendOptions.password', $formValues['password']); $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'TYPO3.Flow.persistence.backendOptions.host', $formValues['host']); $this->configurationSource->save(FLOW_PATH_CONFIGURATION . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->distributionSettings); $this->configurationManager->flushConfigurationCache(); $settings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Flow'); $connectionSettings = $settings['persistence']['backendOptions']; try { $this->connectToDatabase($connectionSettings); } catch (\Exception $exception) { if (!$exception instanceof DBALException && !$exception instanceof \PDOException) { throw $exception; } try { $this->createDatabase($connectionSettings, $formValues['dbname']); } catch (DBALException $exception) { throw new SetupException(sprintf('Database "%s" could not be created. Please check the permissions for user "%s". DBAL Exception: "%s"', $formValues['dbname'], $formValues['user'], $exception->getMessage()), 1351000841, $exception); } catch (\PDOException $exception) { throw new SetupException(sprintf('Database "%s" could not be created. Please check the permissions for user "%s". PDO Exception: "%s"', $formValues['dbname'], $formValues['user'], $exception->getMessage()), 1346758663, $exception); } try { $this->connectToDatabase($connectionSettings); } catch (DBALException $exception) { throw new SetupException(sprintf('Could not connect to database "%s". Please check the permissions for user "%s". DBAL Exception: "%s"', $formValues['dbname'], $formValues['user'], $exception->getMessage()), 1351000864); } catch (\PDOException $exception) { throw new SetupException(sprintf('Could not connect to database "%s". Please check the permissions for user "%s". PDO Exception: "%s"', $formValues['dbname'], $formValues['user'], $exception->getMessage()), 1346758737); } } $migrationExecuted = Scripts::executeCommand('typo3.flow:doctrine:migrate', $settings, FALSE); if ($migrationExecuted !== TRUE) { throw new SetupException(sprintf('Could not execute database migrations. Please check the permissions for user "%s" and execute "./flow typo3.flow:doctrine:migrate" manually.', $formValues['user']), 1346759486); } $this->resetPolicyRolesCacheAfterDatabaseChanges(); }
/** * Bootstraps the minimal infrastructure, resolves a fitting request handler and * then passes control over to that request handler. * * @return void * @api */ public function run() { Scripts::initializeClassLoader($this); Scripts::initializeSignalSlot($this); Scripts::initializePackageManagement($this); $this->activeRequestHandler = $this->resolveRequestHandler(); $this->activeRequestHandler->handleRequest(); }
/** * @param PresetPartDefinition $partSetting * @return integer */ protected function executeCommand(PresetPartDefinition $partSetting) { $startTime = microtime(TRUE); ob_start(); $status = Scripts::executeCommand('ttree.contentrepositoryimporter:import:executebatch', $this->getFlowSettings(), TRUE, $partSetting->getCommandArguments()); $count = (int) ob_get_clean(); $elapsedTime = (microtime(TRUE) - $startTime) * 1000; $this->elapsedTime += $elapsedTime; ++$this->batchCounter; if ($count > 0) { $this->outputLine(' #%d %d records in %dms, %d ms per record, %d ms per batch (avg)', [$partSetting->getCurrentBatch(), $count, $elapsedTime, $elapsedTime / $count, $this->elapsedTime / $this->batchCounter]); } if ($status !== TRUE) { $this->outputLine("Command '%s' return an error", [$partSetting->getLabel()]); $this->quit(1); } return $count; }