コード例 #1
0
 /**
  * Sets up this test case
  *
  */
 protected function setUp()
 {
     ComposerUtility::flushCaches();
     vfsStream::setup('Test');
     $this->mockBootstrap = $this->getMockBuilder(Bootstrap::class)->disableOriginalConstructor()->getMock();
     $this->mockBootstrap->expects($this->any())->method('getSignalSlotDispatcher')->will($this->returnValue($this->createMock(\TYPO3\Flow\SignalSlot\Dispatcher::class)));
     $this->mockApplicationContext = $this->getMockBuilder(ApplicationContext::class)->disableOriginalConstructor()->getMock();
     $this->mockBootstrap->expects($this->any())->method('getContext')->will($this->returnValue($this->mockApplicationContext));
     $mockObjectManager = $this->createMock(\TYPO3\Flow\Object\ObjectManagerInterface::class);
     $this->mockBootstrap->expects($this->any())->method('getObjectManager')->will($this->returnValue($mockObjectManager));
     $mockReflectionService = $this->createMock(\TYPO3\Flow\Reflection\ReflectionService::class);
     $mockReflectionService->expects($this->any())->method('getClassNameByObject')->will($this->returnCallback(function ($object) {
         if ($object instanceof \Doctrine\ORM\Proxy\Proxy) {
             return get_parent_class($object);
         }
         return get_class($object);
     }));
     $mockObjectManager->expects($this->any())->method('get')->with(\TYPO3\Flow\Reflection\ReflectionService::class)->will($this->returnValue($mockReflectionService));
     mkdir('vfs://Test/Packages/Application', 0700, true);
     mkdir('vfs://Test/Configuration');
     $this->packageManager = new PackageManager('vfs://Test/Configuration/PackageStates.php');
     $composerNameToPackageKeyMap = array('typo3/flow' => 'TYPO3.Flow');
     $this->inject($this->packageManager, 'composerNameToPackageKeyMap', $composerNameToPackageKeyMap);
     $this->inject($this->packageManager, 'packagesBasePath', 'vfs://Test/Packages/');
     $this->mockDispatcher = $this->getMockBuilder(Dispatcher::class)->disableOriginalConstructor()->getMock();
     $this->inject($this->packageManager, 'dispatcher', $this->mockDispatcher);
     $this->packageManager->initialize($this->mockBootstrap);
 }
コード例 #2
0
 /**
  * @param string $path
  * @return string
  * @throws \Exception
  */
 public function render($path = NULL)
 {
     if ($path === NULL) {
         $path = '404';
     }
     /** @var RequestHandler $activeRequestHandler */
     $activeRequestHandler = $this->bootstrap->getActiveRequestHandler();
     $parentHttpRequest = $activeRequestHandler->getHttpRequest();
     $requestPath = $parentHttpRequest->getUri()->getPath();
     $language = explode('/', ltrim($requestPath, '/'))[0];
     if ($language === 'neos') {
         throw new \Exception('NotFoundViewHelper can not be used for neos-routes.', 1435648210);
     }
     $language = $this->localeDetector->detectLocaleFromLocaleTag($language)->getLanguage();
     if ($this->contentDimensionPresetSource->findPresetByUriSegment('language', $language) === NULL) {
         $language = '';
     }
     if ($language !== '') {
         $language .= '/';
     }
     $request = Request::create(new Uri(rtrim($parentHttpRequest->getBaseUri(), '/') . '/' . $language . $path));
     $matchingRoute = $this->router->route($request);
     if (!$matchingRoute) {
         throw new \Exception(sprintf('Uri with path "%s" could not be found.', rtrim($parentHttpRequest->getBaseUri(), '/') . '/' . $language . $path), 1426446160);
     }
     $response = new Response();
     $objectManager = $this->bootstrap->getObjectManager();
     $baseComponentChain = $objectManager->get('TYPO3\\Flow\\Http\\Component\\ComponentChain');
     $componentContext = new ComponentContext($request, $response);
     $baseComponentChain->handle($componentContext);
     return $response->getContent();
 }
コード例 #3
0
 /**
  * Invokes custom PHP code directly after the package manager has been initialized.
  *
  * @param Bootstrap $bootstrap The current bootstrap
  * @return void
  */
 public function boot(Bootstrap $bootstrap)
 {
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     $context = $bootstrap->getContext();
     if (!$context->isProduction()) {
         $dispatcher->connect('TYPO3\\Flow\\Core\\Booting\\Sequence', 'afterInvokeStep', function ($step) use($bootstrap, $dispatcher) {
             if ($step->getIdentifier() === 'typo3.flow:systemfilemonitor') {
                 $typoScriptFileMonitor = \TYPO3\Flow\Monitor\FileMonitor::createFileMonitorAtBoot('TypoScript_Files', $bootstrap);
                 $packageManager = $bootstrap->getEarlyInstance('TYPO3\\Flow\\Package\\PackageManagerInterface');
                 foreach ($packageManager->getActivePackages() as $packageKey => $package) {
                     if ($packageManager->isPackageFrozen($packageKey)) {
                         continue;
                     }
                     $typoScriptPaths = array($package->getResourcesPath() . 'Private/TypoScript', $package->getResourcesPath() . 'Private/TypoScripts');
                     foreach ($typoScriptPaths as $typoScriptPath) {
                         if (is_dir($typoScriptPath)) {
                             $typoScriptFileMonitor->monitorDirectory($typoScriptPath);
                         }
                     }
                 }
                 $typoScriptFileMonitor->detectChanges();
                 $typoScriptFileMonitor->shutdownObject();
             }
             if ($step->getIdentifier() === 'typo3.flow:cachemanagement') {
                 $cacheManager = $bootstrap->getEarlyInstance('TYPO3\\Flow\\Cache\\CacheManager');
                 $listener = new \TYPO3\TypoScript\Core\Cache\FileMonitorListener($cacheManager);
                 $dispatcher->connect('TYPO3\\Flow\\Monitor\\FileMonitor', 'filesHaveChanged', $listener, 'flushContentCacheOnFileChanges');
             }
         });
     }
 }
コード例 #4
0
 /**
  * Sends the given HTTP request
  *
  * @param Http\Request $httpRequest
  * @return Http\Response
  * @throws Http\Exception
  * @api
  */
 public function sendRequest(Http\Request $httpRequest)
 {
     $requestHandler = $this->bootstrap->getActiveRequestHandler();
     if (!$requestHandler instanceof FunctionalTestRequestHandler) {
         throw new Http\Exception('The browser\'s internal request engine has only been designed for use within functional tests.', 1335523749);
     }
     $this->securityContext->clearContext();
     $this->validatorResolver->reset();
     $response = new Http\Response();
     $requestHandler->setHttpRequest($httpRequest);
     $requestHandler->setHttpResponse($response);
     $objectManager = $this->bootstrap->getObjectManager();
     $baseComponentChain = $objectManager->get(\TYPO3\Flow\Http\Component\ComponentChain::class);
     $componentContext = new ComponentContext($httpRequest, $response);
     if (version_compare(PHP_VERSION, '6.0.0') >= 0) {
         try {
             $baseComponentChain->handle($componentContext);
         } catch (\Throwable $throwable) {
             $this->prepareErrorResponse($throwable, $response);
         }
     } else {
         try {
             $baseComponentChain->handle($componentContext);
         } catch (\Exception $exception) {
             $this->prepareErrorResponse($exception, $response);
         }
     }
     $session = $this->bootstrap->getObjectManager()->get(\TYPO3\Flow\Session\SessionInterface::class);
     if ($session->isStarted()) {
         $session->close();
     }
     return $response;
 }
コード例 #5
0
ファイル: Package.php プロジェクト: randomresult/WMDB.Forger
 /**
  * @param Bootstrap $bootstrap
  */
 public function boot(Bootstrap $bootstrap)
 {
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     $dispatcher->connect('TYPO3\\Flow\\Configuration\\ConfigurationManager', 'configurationManagerReady', function ($configurationManager) {
         $configurationManager->registerConfigurationType('Sprints');
     });
 }
コード例 #6
0
ファイル: Package.php プロジェクト: nezaniel/systemnodes
 /**
  * @param Bootstrap $bootstrap The current bootstrap
  * @return void
  */
 public function boot(Bootstrap $bootstrap)
 {
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     $dispatcher->connect('TYPO3\\TYPO3CR\\Domain\\Model\\Node', 'nodeUpdated', 'Nezaniel\\SystemNodes\\Service\\SystemNodeService', 'refreshCacheIfNecessary');
     $dispatcher->connect('TYPO3\\TYPO3CR\\Domain\\Model\\Node', 'nodeAdded', 'Nezaniel\\SystemNodes\\Service\\SystemNodeService', 'refreshCacheIfNecessary');
     $dispatcher->connect('TYPO3\\TYPO3CR\\Domain\\Model\\Node', 'nodeRemoved', 'Nezaniel\\SystemNodes\\Service\\SystemNodeService', 'refreshCacheIfNecessary');
 }
コード例 #7
0
ファイル: Package.php プロジェクト: lightwerk/surfcaptain
 /**
  * Boot the package. We wire some signals to slots here.
  *
  * @param \TYPO3\Flow\Core\Bootstrap $bootstrap The current bootstrap
  * @return void
  */
 public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap)
 {
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     $dispatcher->connect('Lightwerk\\SurfCaptain\\GitApi\\ApiRequest', 'apiCall', 'Lightwerk\\SurfCaptain\\GitApi\\RequestListener', 'saveApiCall');
     $dispatcher->connect('Lightwerk\\SurfCaptain\\GitApi\\ApiRequest', 'apiCall', 'Lightwerk\\SurfCaptain\\GitApi\\RequestListener', 'logApiCall');
     $dispatcher->connect('Lightwerk\\SurfCaptain\\GitApi\\ApiRequest', 'beforeApiCall', 'Lightwerk\\SurfCaptain\\GitApi\\RequestListener', 'logBeforeApiCall');
 }
コード例 #8
0
 /**
  * @test
  * @dataProvider commandIdentifiersAndCompiletimeControllerInfo
  */
 public function isCompileTimeCommandControllerChecksIfTheGivenCommandIdentifierRefersToACompileTimeController($compiletimeCommandControllerIdentifiers, $givenCommandIdentifier, $expectedResult)
 {
     $bootstrap = new Bootstrap('Testing');
     foreach ($compiletimeCommandControllerIdentifiers as $compiletimeCommandControllerIdentifier) {
         $bootstrap->registerCompiletimeCommand($compiletimeCommandControllerIdentifier);
     }
     $this->assertSame($expectedResult, $bootstrap->isCompiletimeCommand($givenCommandIdentifier));
 }
コード例 #9
0
ファイル: Package.php プロジェクト: neos/metadata-extractor
 /**
  * Registers slots for signals in order to be able to index nodes
  *
  * @param Bootstrap $bootstrap
  */
 public function registerExtractionSlot(Bootstrap $bootstrap)
 {
     $configurationManager = $bootstrap->getObjectManager()->get(ConfigurationManager::class);
     $settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->getPackageKey());
     if (isset($settings['realtimeExtraction']['enabled']) && $settings['realtimeExtraction']['enabled'] === TRUE) {
         $dispatcher = $bootstrap->getSignalSlotDispatcher();
         $dispatcher->connect(Asset::class, 'assetCreated', ExtractionManager::class, 'extractMetaData');
     }
 }
コード例 #10
0
 /**
  * @return \TYPO3\Neos\Domain\Model\Domain
  */
 public function findOneByActiveRequest()
 {
     $matchingDomain = null;
     $activeRequestHandler = $this->bootstrap->getActiveRequestHandler();
     if ($activeRequestHandler instanceof \TYPO3\Flow\Http\HttpRequestHandlerInterface) {
         $matchingDomain = $this->findOneByHost($activeRequestHandler->getHttpRequest()->getUri()->getHost(), true);
     }
     return $matchingDomain;
 }
コード例 #11
0
 /**
  * @param \TYPO3\Flow\Core\Bootstrap $bootstrap
  */
 public function prepareRealtimeIndexing(\TYPO3\Flow\Core\Bootstrap $bootstrap)
 {
     $this->configurationManager = $bootstrap->getObjectManager()->get('TYPO3\\Flow\\Configuration\\ConfigurationManager');
     $settings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->getPackageKey());
     if (isset($settings['realtimeIndexing']['enabled']) && $settings['realtimeIndexing']['enabled'] === TRUE) {
         $bootstrap->getSignalSlotDispatcher()->connect('Flowpack\\ElasticSearch\\Indexer\\Object\\Signal\\SignalEmitter', 'objectUpdated', 'Flowpack\\ElasticSearch\\Indexer\\Object\\ObjectIndexer', 'indexObject');
         $bootstrap->getSignalSlotDispatcher()->connect('Flowpack\\ElasticSearch\\Indexer\\Object\\Signal\\SignalEmitter', 'objectPersisted', 'Flowpack\\ElasticSearch\\Indexer\\Object\\ObjectIndexer', 'indexObject');
         $bootstrap->getSignalSlotDispatcher()->connect('Flowpack\\ElasticSearch\\Indexer\\Object\\Signal\\SignalEmitter', 'objectRemoved', 'Flowpack\\ElasticSearch\\Indexer\\Object\\ObjectIndexer', 'removeObject');
     }
 }
コード例 #12
0
ファイル: Package.php プロジェクト: lightwerk/surfrunner
 /**
  * Invokes custom PHP code directly after the package manager has been
  * initialized.
  *
  * @param Bootstrap $bootstrap The current bootstrap
  * @return void
  */
 public function boot(Bootstrap $bootstrap)
 {
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     // HitChat Notifier
     $dispatcher->connect('Lightwerk\\SurfRunner\\Service\\DeploymentService', 'deploymentStarted', 'Lightwerk\\SurfRunner\\Notification\\HitChatNotifier', 'deploymentStarted');
     $dispatcher->connect('Lightwerk\\SurfRunner\\Service\\DeploymentService', 'deploymentFinished', 'Lightwerk\\SurfRunner\\Notification\\HitChatNotifier', 'deploymentFinished');
     // Email Notifier
     $dispatcher->connect('Lightwerk\\SurfRunner\\Service\\DeploymentService', 'deploymentStarted', 'Lightwerk\\SurfRunner\\Notification\\EmailNotifier', 'deploymentStarted');
     $dispatcher->connect('Lightwerk\\SurfRunner\\Service\\DeploymentService', 'deploymentFinished', 'Lightwerk\\SurfRunner\\Notification\\EmailNotifier', 'deploymentFinished');
 }
コード例 #13
0
ファイル: Package.php プロジェクト: rfyio/Radmiraal.CouchDB
 /**
  * @param \TYPO3\Flow\Core\Bootstrap $bootstrap The current bootstrap
  * @return void
  */
 public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap)
 {
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     $dispatcher->connect('TYPO3\\Flow\\Mvc\\Dispatcher', 'afterControllerInvocation', function ($request) use($bootstrap) {
         if (!$request instanceof \TYPO3\Flow\Mvc\ActionRequest || $request->getHttpRequest()->isMethodSafe() !== TRUE) {
             $bootstrap->getObjectManager()->get('Radmiraal\\CouchDB\\CouchDBHelper')->flush();
         }
     });
     $dispatcher->connect('TYPO3\\Flow\\Cli\\SlaveRequestHandler', 'dispatchedCommandLineSlaveRequest', 'Radmiraal\\CouchDB\\CouchDBHelper', 'flush');
 }
コード例 #14
0
ファイル: Package.php プロジェクト: radmiraal/TYPO3.TYPO3CR
 /**
  * Invokes custom PHP code directly after the package manager has been initialized.
  *
  * @param \TYPO3\Flow\Core\Bootstrap $bootstrap The current bootstrap
  * @return void
  */
 public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap)
 {
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     $dispatcher->connect('TYPO3\\Flow\\Persistence\\Doctrine\\PersistenceManager', 'allObjectsPersisted', 'TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository', 'flushNodeRegistry');
     $dispatcher->connect('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository', 'repositoryObjectsPersisted', 'TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository', 'flushNodeRegistry');
     $dispatcher->connect('TYPO3\\TYPO3CR\\Domain\\Model\\NodeData', 'nodePathChanged', 'TYPO3\\Flow\\Mvc\\Routing\\RouterCachingService', 'flushCaches');
     $dispatcher->connect('TYPO3\\Flow\\Configuration\\ConfigurationManager', 'configurationManagerReady', function ($configurationManager) {
         $configurationManager->registerConfigurationType('NodeTypes', \TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_DEFAULT);
     });
 }
コード例 #15
0
ファイル: Package.php プロジェクト: flow2lab/eventsourcing
 /**
  * Invokes custom PHP code directly after the package manager has been initialized.
  *
  * @param Bootstrap $bootstrap The current bootstrap
  * @return void
  */
 public function boot(Bootstrap $bootstrap)
 {
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     # Command Auditing
     $dispatcher->connect('Flow2Lab\\EventSourcing\\Command\\Bus\\InternalCommandBus', 'commandHandlingSuccess', 'Flow2Lab\\EventSourcing\\Auditing\\CommandLogger', 'onCommandHandlingSuccess');
     $dispatcher->connect('Flow2Lab\\EventSourcing\\Command\\Bus\\InternalCommandBus', 'commandHandlingFailure', 'Flow2Lab\\EventSourcing\\Auditing\\CommandLogger', 'onCommandHandlingFailure');
     # Event Auditing
     $dispatcher->connect('Flow2Lab\\EventSourcing\\Event\\Bus\\InternalEventBus', 'eventHandlingSuccess', 'Flow2Lab\\EventSourcing\\Auditing\\EventLogger', 'onEventHandlingSuccess');
     $dispatcher->connect('Flow2Lab\\EventSourcing\\Event\\Bus\\InternalEventBus', 'eventHandlingFailure', 'Flow2Lab\\EventSourcing\\Auditing\\EventLogger', 'onEventHandlingFailure');
     $dispatcher->connect('Flow2Lab\\EventSourcing\\Event\\Bus\\InternalEventBus', 'eventQueueingSuccess', 'Flow2Lab\\EventSourcing\\Auditing\\EventLogger', 'onEventQueueingSuccess');
 }
コード例 #16
0
ファイル: Package.php プロジェクト: HofUniversityIWS/backend
 /**
  * @param Bootstrap $bootstrap The current bootstrap
  * @return void
  */
 public function boot(Bootstrap $bootstrap)
 {
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     $dispatcher->connect('TYPO3\\Flow\\Core\\Booting\\Sequence', 'afterInvokeStep', function ($step) use($bootstrap) {
         if ($step instanceof \TYPO3\Flow\Core\Booting\Step && $step->getIdentifier() == 'typo3.flow:persistence') {
             /** @var \Doctrine\Common\Persistence\ObjectManager $entityManager */
             $entityManager = $bootstrap->getObjectManager()->get(\Doctrine\Common\Persistence\ObjectManager::class);
             $entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
         }
     });
 }
コード例 #17
0
 public function setUp()
 {
     $this->fileSystemTarget = new FileSystemTarget('test');
     $this->mockBootstrap = $this->getMockBuilder(Bootstrap::class)->disableOriginalConstructor()->getMock();
     $this->mockRequestHandler = $this->getMockBuilder(HttpRequestHandlerInterface::class)->getMock();
     $this->mockHttpRequest = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
     $this->mockHttpRequest->expects($this->any())->method('getBaseUri')->will($this->returnValue(new Uri('http://detected/base/uri/')));
     $this->mockRequestHandler->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest));
     $this->mockBootstrap->expects($this->any())->method('getActiveRequestHandler')->will($this->returnValue($this->mockRequestHandler));
     $this->inject($this->fileSystemTarget, 'bootstrap', $this->mockBootstrap);
 }
コード例 #18
0
 /**
  * {@inheritdoc}
  */
 public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap)
 {
     require_once FLOW_PATH_PACKAGES . '/Libraries/raven/raven/lib/Raven/Autoloader.php';
     \Raven_Autoloader::register();
     $bootstrap->getSignalSlotDispatcher()->connect('TYPO3\\Flow\\Core\\Booting\\Sequence', 'afterInvokeStep', function ($step, $runlevel) use($bootstrap) {
         if ($step->getIdentifier() === 'typo3.flow:objectmanagement:runtime') {
             // This triggers the initializeObject method
             $bootstrap->getObjectManager()->get('Networkteam\\SentryClient\\ErrorHandler');
         }
     });
 }
コード例 #19
0
ファイル: CsrfProtectionAspect.php プロジェクト: neos/extjs
 /**
  * Adds a CSRF token as argument in ExtDirect requests
  *
  * @Flow\Around("method(TYPO3\ExtJS\ExtDirect\Transaction->buildRequest()) && setting(TYPO3.Flow.security.enable)")
  * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point
  * @return \TYPO3\Flow\Mvc\ActionRequest
  */
 public function transferCsrfTokenToExtDirectRequests(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint)
 {
     $extDirectRequest = $joinPoint->getAdviceChain()->proceed($joinPoint);
     $requestHandler = $this->bootstrap->getActiveRequestHandler();
     if ($requestHandler instanceof \TYPO3\Flow\Http\HttpRequestHandlerInterface) {
         $arguments = $requestHandler->getHttpRequest()->getArguments();
         if (isset($arguments['__csrfToken'])) {
             $requestArguments = $extDirectRequest->getMainRequest()->getArguments();
             $requestArguments['__csrfToken'] = $arguments['__csrfToken'];
             $extDirectRequest->getMainRequest()->setArguments($requestArguments);
         }
     }
     return $extDirectRequest;
 }
コード例 #20
0
 /**
  * Retrieve current authenticated account
  *
  * @return \TYPO3\Flow\Security\Account|NULL
  */
 public static function getAuthenticatedAccount()
 {
     self::initializeBootstrap();
     if (self::$bootstrap) {
         $objectManager = self::$bootstrap->getObjectManager();
         if ($objectManager) {
             $securityContext = $objectManager->get('\\TYPO3\\Flow\\Security\\Context');
             if ($securityContext && $securityContext->canBeInitialized()) {
                 return $securityContext->getAccount();
             }
         }
     }
     return null;
 }
コード例 #21
0
 /**
  * {@inheritdoc}
  */
 public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap)
 {
     require_once FLOW_PATH_PACKAGES . '/Libraries/raven/raven/lib/Raven/Autoloader.php';
     \Raven_Autoloader::register();
     $bootstrap->getSignalSlotDispatcher()->connect('TYPO3\\Flow\\Core\\Booting\\Sequence', 'afterInvokeStep', function ($step, $runlevel) use($bootstrap) {
         if ($step->getIdentifier() === 'typo3.flow:objectmanagement:runtime') {
             // This triggers the initializeObject method
             $bootstrap->getObjectManager()->get('Networkteam\\SentryClient\\ErrorHandler');
         }
     });
     // Make Sentry DSN settable via Environment Variables. Only used in context Production/Heroku.
     if (getenv('ENV_SENTRY_DSN')) {
         define('ENV_SENTRY_DSN', getenv('ENV_SENTRY_DSN'));
     }
 }
コード例 #22
0
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setup();
     vfsStream::setup('Foo');
     $this->httpRequest = Request::create(new Uri('http://localhost'));
     $this->httpResponse = new Response();
     $mockRequestHandler = $this->createMock(\TYPO3\Flow\Http\RequestHandler::class, array(), array(), '', false, false);
     $mockRequestHandler->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->httpRequest));
     $mockRequestHandler->expects($this->any())->method('getHttpResponse')->will($this->returnValue($this->httpResponse));
     $this->mockBootstrap = $this->createMock(\TYPO3\Flow\Core\Bootstrap::class, array(), array(), '', false, false);
     $this->mockBootstrap->expects($this->any())->method('getActiveRequestHandler')->will($this->returnValue($mockRequestHandler));
     $this->mockSecurityContext = $this->createMock(\TYPO3\Flow\Security\Context::class, array(), array(), '', false, false);
     $this->mockObjectManager = $this->createMock(\TYPO3\Flow\Object\ObjectManagerInterface::class, array(), array(), '', false, false);
     $this->mockObjectManager->expects($this->any())->method('get')->with(\TYPO3\Flow\Security\Context::class)->will($this->returnValue($this->mockSecurityContext));
 }
コード例 #23
0
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setup();
     vfsStream::setup('Foo');
     $this->httpRequest = Request::create(new Uri('http://localhost'));
     $this->httpResponse = new Response();
     $mockRequestHandler = $this->getMock('TYPO3\\Flow\\Http\\RequestHandler', array(), array(), '', FALSE, FALSE);
     $mockRequestHandler->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->httpRequest));
     $mockRequestHandler->expects($this->any())->method('getHttpResponse')->will($this->returnValue($this->httpResponse));
     $this->mockBootstrap = $this->getMock('TYPO3\\Flow\\Core\\Bootstrap', array(), array(), '', FALSE, FALSE);
     $this->mockBootstrap->expects($this->any())->method('getActiveRequestHandler')->will($this->returnValue($mockRequestHandler));
     $this->mockSecurityContext = $this->getMock('TYPO3\\Flow\\Security\\Context', array(), array(), '', FALSE, FALSE);
     $this->mockObjectManager = $this->getMock('TYPO3\\Flow\\Object\\ObjectManagerInterface', array(), array(), '', FALSE, FALSE);
     $this->mockObjectManager->expects($this->any())->method('get')->with('TYPO3\\Flow\\Security\\Context')->will($this->returnValue($this->mockSecurityContext));
 }
コード例 #24
0
 /**
  * Returns an array that contains all available command identifiers and their shortest non-ambiguous alias
  *
  * @return array in the format array('full.command:identifier1' => 'alias1', 'full.command:identifier2' => 'alias2')
  */
 protected function getShortCommandIdentifiers()
 {
     if ($this->shortCommandIdentifiers === null) {
         $commandsByCommandName = [];
         /** @var Command $availableCommand */
         foreach ($this->getAvailableCommands() as $availableCommand) {
             list($packageKey, $controllerName, $commandName) = explode(':', $availableCommand->getCommandIdentifier());
             if (!isset($commandsByCommandName[$commandName])) {
                 $commandsByCommandName[$commandName] = [];
             }
             if (!isset($commandsByCommandName[$commandName][$controllerName])) {
                 $commandsByCommandName[$commandName][$controllerName] = [];
             }
             $commandsByCommandName[$commandName][$controllerName][] = $packageKey;
         }
         foreach ($this->getAvailableCommands() as $availableCommand) {
             list($packageKey, $controllerName, $commandName) = explode(':', $availableCommand->getCommandIdentifier());
             if (count($commandsByCommandName[$commandName][$controllerName]) > 1 || $this->bootstrap->isCompiletimeCommand($availableCommand->getCommandIdentifier())) {
                 $packageKeyParts = array_reverse(explode('.', $packageKey));
                 for ($i = 1; $i <= count($packageKeyParts); $i++) {
                     $shortCommandIdentifier = implode('.', array_slice($packageKeyParts, 0, $i)) . ':' . $controllerName . ':' . $commandName;
                     try {
                         $this->getCommandByIdentifier($shortCommandIdentifier);
                         $this->shortCommandIdentifiers[$availableCommand->getCommandIdentifier()] = $shortCommandIdentifier;
                         break;
                     } catch (CommandException $exception) {
                     }
                 }
             } else {
                 $this->shortCommandIdentifiers[$availableCommand->getCommandIdentifier()] = sprintf('%s:%s', $controllerName, $commandName);
             }
         }
     }
     return $this->shortCommandIdentifiers;
 }
コード例 #25
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->baseComponentChain = $objectManager->get('TYPO3\\Flow\\Http\\Component\\ComponentChain');
     $configurationManager = $objectManager->get('TYPO3\\Flow\\Configuration\\ConfigurationManager');
     $this->settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Flow');
 }
コード例 #26
0
 /**
  * Helper method to create a FileMonitor instance during boot sequence as injections have to be done manually.
  *
  * @param string $identifier
  * @param Bootstrap $bootstrap
  * @return FileMonitor
  */
 public static function createFileMonitorAtBoot($identifier, Bootstrap $bootstrap)
 {
     $fileMonitorCache = $bootstrap->getEarlyInstance('TYPO3\\Flow\\Cache\\CacheManager')->getCache('Flow_Monitor');
     // The change detector needs to be instantiated and registered manually because
     // it has a complex dependency (cache) but still needs to be a singleton.
     $fileChangeDetector = new \TYPO3\Flow\Monitor\ChangeDetectionStrategy\ModificationTimeStrategy();
     $fileChangeDetector->injectCache($fileMonitorCache);
     $bootstrap->getObjectManager()->registerShutdownObject($fileChangeDetector, 'shutdownObject');
     $fileMonitor = new FileMonitor($identifier);
     $fileMonitor->injectCache($fileMonitorCache);
     $fileMonitor->injectChangeDetectionStrategy($fileChangeDetector);
     $fileMonitor->injectSignalDispatcher($bootstrap->getEarlyInstance('TYPO3\\Flow\\SignalSlot\\Dispatcher'));
     $fileMonitor->injectSystemLogger($bootstrap->getEarlyInstance('TYPO3\\Flow\\Log\\SystemLoggerInterface'));
     $fileMonitor->initializeObject();
     return $fileMonitor;
 }
コード例 #27
0
 /**
  * Flush all caches
  *
  * The flush command flushes all caches (including code caches) which have been
  * registered with Flow's Cache Manager. It also removes any session data.
  *
  * If fatal errors caused by a package prevent the compile time bootstrap
  * from running, the removal of any temporary data can be forced by specifying
  * the option <b>--force</b>.
  *
  * This command does not remove the precompiled data provided by frozen
  * packages unless the <b>--force</b> option is used.
  *
  * @param boolean $force Force flushing of any temporary data
  * @return void
  * @see typo3.flow:cache:warmup
  * @see typo3.flow:package:freeze
  * @see typo3.flow:package:refreeze
  */
 public function flushCommand($force = FALSE)
 {
     // Internal note: the $force option is evaluated early in the Flow
     // bootstrap in order to reliably flush the temporary data before any
     // other code can cause fatal errors.
     $this->cacheManager->flushCaches();
     $dataTemporaryPath = $this->environment->getPathToTemporaryDirectory();
     \TYPO3\Flow\Utility\Files::unlink($dataTemporaryPath . 'AvailableProxyClasses.php');
     $this->outputLine('Flushed all caches for "' . $this->bootstrap->getContext() . '" context.');
     if ($this->lockManager->isSiteLocked()) {
         $this->lockManager->unlockSite();
     }
     $frozenPackages = array();
     foreach (array_keys($this->packageManager->getActivePackages()) as $packageKey) {
         if ($this->packageManager->isPackageFrozen($packageKey)) {
             $frozenPackages[] = $packageKey;
         }
     }
     if ($frozenPackages !== array()) {
         $this->outputFormatted(PHP_EOL . 'Please note that the following package' . (count($frozenPackages) === 1 ? ' is' : 's are') . ' currently frozen: ' . PHP_EOL);
         $this->outputFormatted(implode(PHP_EOL, $frozenPackages) . PHP_EOL, array(), 2);
         $message = 'As code and configuration changes in these packages are not detected, the application may respond ';
         $message .= 'unexpectedly if modifications were done anyway or the remaining code relies on these changes.' . PHP_EOL . PHP_EOL;
         $message .= 'You may call <b>package:refreeze all</b> in order to refresh frozen packages or use the <b>--force</b> ';
         $message .= 'option of this <b>cache:flush</b> command to flush caches if Flow becomes unresponsive.' . PHP_EOL;
         $this->outputFormatted($message, array($frozenPackages));
     }
     $this->sendAndExit(0);
 }
コード例 #28
0
 /**
  * @return \TYPO3\Flow\Http\Request
  */
 protected function getHttpRequest()
 {
     $requestHandler = $this->bootstrap->getActiveRequestHandler();
     if ($requestHandler instanceof \TYPO3\Flow\Http\HttpRequestHandlerInterface) {
         return $requestHandler->getHttpRequest();
     }
 }
コード例 #29
0
 /**
  * Emits a signal when package states have been changed (e.g. when a package was created or activated)
  *
  * The advice is not proxyable, so the signal is dispatched manually here.
  *
  * @return void
  * @Flow\Signal
  */
 protected function emitPackageStatesUpdated()
 {
     if ($this->dispatcher === null) {
         $this->dispatcher = $this->bootstrap->getEarlyInstance(Dispatcher::class);
     }
     $this->dispatcher->dispatch(PackageManager::class, 'packageStatesUpdated');
 }
コード例 #30
0
 /**
  * Adds an HTTP header to the Response which indicates that the application is powered by Flow.
  *
  * @param Response $response
  * @return void
  */
 protected function addPoweredByHeader(Response $response)
 {
     if ($this->settings['http']['applicationToken'] === 'Off') {
         return;
     }
     $applicationIsFlow = $this->settings['core']['applicationPackageKey'] === 'TYPO3.Flow';
     if ($this->settings['http']['applicationToken'] === 'ApplicationName') {
         if ($applicationIsFlow) {
             $response->getHeaders()->set('X-Flow-Powered', 'Flow');
         } else {
             $response->getHeaders()->set('X-Flow-Powered', 'Flow ' . $this->settings['core']['applicationName']);
         }
         return;
     }
     /** @var Package $applicationPackage */
     /** @var Package $flowPackage */
     $flowPackage = $this->bootstrap->getEarlyInstance('TYPO3\\Flow\\Package\\PackageManagerInterface')->getPackage('TYPO3.Flow');
     $applicationPackage = $this->bootstrap->getEarlyInstance('TYPO3\\Flow\\Package\\PackageManagerInterface')->getPackage($this->settings['core']['applicationPackageKey']);
     if ($this->settings['http']['applicationToken'] === 'MajorVersion') {
         $flowVersion = $this->renderMajorVersion($flowPackage->getInstalledVersion());
         $applicationVersion = $this->renderMajorVersion($applicationPackage->getInstalledVersion());
     } else {
         $flowVersion = $this->renderMinorVersion($flowPackage->getInstalledVersion());
         $applicationVersion = $this->renderMinorVersion($applicationPackage->getInstalledVersion());
     }
     if ($applicationIsFlow) {
         $response->getHeaders()->set('X-Flow-Powered', 'Flow/' . ($flowVersion ?: 'dev'));
     } else {
         $response->getHeaders()->set('X-Flow-Powered', 'Flow/' . ($flowVersion ?: 'dev') . ' ' . $this->settings['core']['applicationName'] . '/' . ($applicationVersion ?: 'dev'));
     }
 }