Example #1
0
 /**
  * Creates an event loop which takes orders from the parent process and executes
  * them in runtime mode.
  *
  * @return void
  */
 public function handleRequest()
 {
     $sequence = $this->bootstrap->buildRuntimeSequence();
     $sequence->invoke($this->bootstrap);
     $objectManager = $this->bootstrap->getObjectManager();
     $systemLogger = $objectManager->get('TYPO3\\FLOW3\\Log\\SystemLoggerInterface');
     $systemLogger->log('Running sub process loop.', LOG_DEBUG);
     echo "\nREADY\n";
     try {
         while (TRUE) {
             $commandLine = trim(fgets(STDIN));
             $systemLogger->log(sprintf('Received command "%s".', $commandLine), LOG_INFO);
             if ($commandLine === "QUIT\n") {
                 break;
             }
             $request = $objectManager->get('TYPO3\\FLOW3\\Cli\\RequestBuilder')->build($commandLine);
             $response = new \TYPO3\FLOW3\Cli\Response();
             if ($this->bootstrap->isCompiletimeCommand($request->getCommand()->getCommandIdentifier())) {
                 echo "This command must be executed during compiletime.\n";
             } else {
                 $objectManager->get('TYPO3\\FLOW3\\Mvc\\Dispatcher')->dispatch($request, $response);
                 $response->send();
                 $this->emitDispatchedCommandLineSlaveRequest();
             }
             echo "\nREADY\n";
         }
         $systemLogger->log('Exiting sub process loop.', LOG_DEBUG);
         $this->bootstrap->shutdown('Runtime');
         exit($response->getExitCode());
     } catch (\Exception $exception) {
         $this->handleException($exception);
     }
 }
Example #2
0
 /**
  * Initializes the matching boot sequence depending on the type of the command
  * (runtime or compiletime) and manually injects the necessary dependencies of
  * this request handler.
  *
  * @param string $runlevel Either "Compiletime" or "Runtime"
  * @return void
  */
 protected function boot($runlevel)
 {
     $sequence = $runlevel === 'Compiletime' ? $this->bootstrap->buildCompiletimeSequence() : $this->bootstrap->buildRuntimeSequence();
     $sequence->invoke($this->bootstrap);
     $this->objectManager = $this->bootstrap->getObjectManager();
     $this->dispatcher = $this->objectManager->get('TYPO3\\FLOW3\\Mvc\\Dispatcher');
 }
Example #3
0
 /**
  * Refreezes a package
  *
  * @param string $packageKey The package to refreeze
  * @return void
  */
 public function refreezePackage($packageKey)
 {
     if (!$this->isPackageFrozen($packageKey)) {
         return;
     }
     $this->bootstrap->getObjectManager()->get('TYPO3\\FLOW3\\Reflection\\ReflectionService')->unfreezePackageReflection($packageKey);
 }
Example #4
0
 /**
  * Resolves a few dependencies of this request handler which can't be resolved
  * automatically due to the early stage of the boot process this request handler
  * is invoked at.
  *
  * @return void
  */
 protected function resolveDependencies()
 {
     $objectManager = $this->bootstrap->getObjectManager();
     $this->dispatcher = $objectManager->get('TYPO3\\FLOW3\\Mvc\\Dispatcher');
     $configurationManager = $objectManager->get('TYPO3\\FLOW3\\Configuration\\ConfigurationManager');
     $this->settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.FLOW3');
     $this->routesConfiguration = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_ROUTES);
     $this->router = $objectManager->get('TYPO3\\FLOW3\\Mvc\\Routing\\Router');
     $this->securityContext = $objectManager->get('TYPO3\\FLOW3\\Security\\Context');
 }
Example #5
0
 /**
  * Returns autocomplete suggestions on hitting the TAB key.
  *
  * @param string $partialCommand The current (partial) command where the TAB key was hit
  * @param integer $index The cursor index at the current (partial) command
  * @return array
  */
 protected function autocomplete($partialCommand, $index)
 {
     // @TODO Add more functionality by parsing the current buffer with readline_info()
     // @TODO Filter file system elements (if possible at all)
     $suggestions = array();
     $availableCommands = $this->bootstrap->getObjectManager()->get('TYPO3\\FLOW3\\Cli\\CommandManager')->getAvailableCommands();
     /** @var $command \TYPO3\FLOW3\Cli\Command */
     foreach ($availableCommands as $command) {
         if ($command->isInternal() === FALSE) {
             $suggestions[] = $command->getCommandIdentifier();
         }
     }
     return $suggestions;
 }
Example #6
0
 /**
  * Tears down test requirements depending on the enabled tests
  *
  * Note: tearDown() is also called if an exception occurred in one of the tests. If the problem is caused by
  *       some security or persistence related part of FLOW3, the error might be hard to track because their
  *       specialized tearDown() methods might cause fatal errors. In those cases just output the original
  *       exception message by adding an echo($this->statusMessage) as the first line of this method.
  *
  * @return void
  */
 public function tearDown()
 {
     if ($this->testableSecurityEnabled === TRUE) {
         $this->tearDownSecurity();
     }
     $persistenceManager = self::$bootstrap->getObjectManager()->get('TYPO3\\FLOW3\\Persistence\\PersistenceManagerInterface');
     // Explicitly call persistAll() so that the "allObjectsPersisted" signal is sent even if persistAll()
     // has not been called during a test. This makes sure that for example certain repositories can clear
     // their internal registry in order to avoid side effects in the following test run.
     // Wrap in try/catch to suppress errors after the actual test is run (e.g. validation)
     try {
         $persistenceManager->persistAll();
     } catch (\Exception $exception) {
     }
     if (is_callable(array($persistenceManager, 'tearDown'))) {
         $persistenceManager->tearDown();
     }
     self::$bootstrap->getObjectManager()->forgetInstance('TYPO3\\FLOW3\\Http\\Client\\InternalRequestEngine');
     $this->emitFunctionalTestTearDown();
 }
Example #7
0
 /**
  * Destroys (file) data from all active PHP sessions.
  *
  * @param \TYPO3\FLOW3\Core\Bootstrap $bootstrap
  * @return integer The number of session files which have been removed
  */
 public static function destroyAll(Bootstrap $bootstrap)
 {
     $settings = $bootstrap->getObjectManager()->get('TYPO3\\FLOW3\\Configuration\\ConfigurationManager')->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.FLOW3');
     if (empty($settings['session']['PhpSession']['savePath'])) {
         $sessionsPath = Files::concatenatePaths(array($bootstrap->getObjectManager()->get('TYPO3\\FLOW3\\Utility\\Environment')->getPathToTemporaryDirectory(), 'Sessions'));
     } else {
         $sessionsPath = $settings['session']['PhpSession']['savePath'];
     }
     if (is_dir($sessionsPath)) {
         $filenames = Files::readDirectoryRecursively($sessionsPath);
         if (count($filenames) > 0) {
             Files::emptyDirectoryRecursively($sessionsPath);
         }
         return count($filenames);
     } else {
         return 0;
     }
 }
Example #8
0
 /**
  * Initialize the resource management component, setting up stream wrappers,
  * publishing the public resources of all found packages, ...
  *
  * @param \TYPO3\FLOW3\Core\Bootstrap $bootstrap
  * @return void
  */
 public static function initializeResources(Bootstrap $bootstrap)
 {
     $packageManager = $bootstrap->getEarlyInstance('TYPO3\\FLOW3\\Package\\PackageManagerInterface');
     $resourceManager = $bootstrap->getObjectManager()->get('TYPO3\\FLOW3\\Resource\\ResourceManager');
     $resourceManager->initialize();
     $resourceManager->publishPublicPackageResources($packageManager->getActivePackages());
 }