/**
  * 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(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(ObjectManagerInterface::class);
     $this->mockBootstrap->expects($this->any())->method('getObjectManager')->will($this->returnValue($mockObjectManager));
     $mockReflectionService = $this->createMock(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(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 = ['neos/flow' => 'Neos.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);
 }
 /**
  * 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(Sequence::class, 'afterInvokeStep', function ($step) use($bootstrap, $dispatcher) {
             if ($step->getIdentifier() === 'typo3.flow:systemfilemonitor') {
                 $typoScriptFileMonitor = FileMonitor::createFileMonitorAtBoot('TypoScript_Files', $bootstrap);
                 $packageManager = $bootstrap->getEarlyInstance(PackageManagerInterface::class);
                 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(CacheManager::class);
                 $listener = new FileMonitorListener($cacheManager);
                 $dispatcher->connect(FileMonitor::class, 'filesHaveChanged', $listener, 'flushContentCacheOnFileChanges');
             }
         });
     }
 }
 /**
  * @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));
 }
 /**
  * @return Domain
  */
 public function findOneByActiveRequest()
 {
     $matchingDomain = null;
     $activeRequestHandler = $this->bootstrap->getActiveRequestHandler();
     if ($activeRequestHandler instanceof HttpRequestHandlerInterface) {
         $matchingDomain = $this->findOneByHost($activeRequestHandler->getHttpRequest()->getUri()->getHost(), true);
     }
     return $matchingDomain;
 }
 public function setUp()
 {
     $this->fileSystemTarget = new FileSystemTarget('test');
     $this->mockBootstrap = $this->getMockBuilder(Bootstrap::class)->disableOriginalConstructor()->getMock();
     $this->mockRequestHandler = $this->createMock(HttpRequestHandlerInterface::class);
     $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);
 }
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setup();
     vfsStream::setup('Foo');
     $this->httpRequest = Http\Request::create(new Http\Uri('http://localhost'));
     $this->httpResponse = new Http\Response();
     $mockRequestHandler = $this->createMock(Http\RequestHandler::class);
     $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(Bootstrap::class);
     $this->mockBootstrap->expects($this->any())->method('getActiveRequestHandler')->will($this->returnValue($mockRequestHandler));
     $this->mockSecurityContext = $this->createMock(Context::class);
     $this->mockObjectManager = $this->createMock(ObjectManagerInterface::class);
     $this->mockObjectManager->expects($this->any())->method('get')->with(Context::class)->will($this->returnValue($this->mockSecurityContext));
 }
 /**
  * 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();
     $componentContext = new ComponentContext($httpRequest, $response);
     $requestHandler->setComponentContext($componentContext);
     $objectManager = $this->bootstrap->getObjectManager();
     $baseComponentChain = $objectManager->get(\Neos\Flow\Http\Component\ComponentChain::class);
     $componentContext = new ComponentContext($httpRequest, $response);
     try {
         $baseComponentChain->handle($componentContext);
     } catch (\Throwable $throwable) {
         $this->prepareErrorResponse($throwable, $componentContext->getHttpResponse());
     } catch (\Exception $exception) {
         $this->prepareErrorResponse($exception, $componentContext->getHttpResponse());
     }
     $session = $this->bootstrap->getObjectManager()->get(SessionInterface::class);
     if ($session->isStarted()) {
         $session->close();
     }
     $this->persistenceManager->clearState();
     return $componentContext->getHttpResponse();
 }
 /**
  * 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;
 }
 /**
  * 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'] === 'Neos.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(PackageManagerInterface::class)->getPackage('Neos.Flow');
     $applicationPackage = $this->bootstrap->getEarlyInstance(PackageManagerInterface::class)->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'));
     }
 }
 /**
  * Starts the shutdown sequence
  *
  * @param string $runlevel one of the Bootstrap::RUNLEVEL_* constants
  * @return void
  */
 protected function shutdown($runlevel)
 {
     $this->bootstrap->shutdown($runlevel);
     if ($runlevel === Bootstrap::RUNLEVEL_COMPILETIME) {
         $this->objectManager->get(LockManager::class)->unlockSite();
     }
     exit($this->response->getExitCode());
 }
Esempio n. 11
0
    /**
     * Display a message. As we cannot rely on any Flow requirements being fulfilled here,
     * we have to statically include the CSS styles at this point, and have to in-line the TYPO3 logo.
     *
     * @param array <\Neos\Error\Messages\Message> $messages Array of messages (at least one message must be passed)
     * @param string $extraHeaderHtml extra HTML code to include at the end of the head tag
     * @return void This method never returns.
     */
    public function showMessages(array $messages, $extraHeaderHtml = '')
    {
        if ($messages === []) {
            throw new \InvalidArgumentException('No messages given for rendering', 1416914970);
        }
        /** @var \Neos\Flow\Package\PackageManagerInterface $packageManager */
        $packageManager = $this->bootstrap->getEarlyInstance(\Neos\Flow\Package\PackageManagerInterface::class);
        $css = '';
        if ($packageManager->isPackageAvailable('Neos.Twitter.Bootstrap')) {
            $css .= file_get_contents($packageManager->getPackage('Neos.Twitter.Bootstrap')->getResourcesPath() . 'Public/3/css/bootstrap.min.css');
            $css = str_replace('url(../', 'url(/_Resources/Static/Packages/Neos.Twitter.Bootstrap/3.0/', $css);
        }
        if ($packageManager->isPackageAvailable('Neos.Setup')) {
            $css .= file_get_contents($packageManager->getPackage('Neos.Setup')->getResourcesPath() . 'Public/Styles/Setup.css');
            $css = str_replace('url(\'../', 'url(\'/_Resources/Static/Packages/Neos.Setup/', $css);
        }
        echo '<html>';
        echo '<head>';
        echo '<title>Setup message</title>';
        echo '<style type="text/css">';
        echo $css;
        echo '</style>';
        echo $extraHeaderHtml;
        echo '</head>';
        echo '<body>';
        $renderedMessages = $this->renderMessages($messages);
        $lastMessage = end($messages);
        echo sprintf('
			<div class="logo"></div>
			<div class="well">
				<div class="container">
					<ul class="breadcrumb">
						<li><a class="active">Setup</a></li>
					</ul>
					<h3>%s</h3>
					<div class="t3-module-container indented">
						%s
					</div>
				</div>
			</div>
			', $lastMessage->getTitle(), $renderedMessages);
        echo '</body></html>';
        exit(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->bootstrap === null) {
         return;
     }
     if ($this->dispatcher === null) {
         $this->dispatcher = $this->bootstrap->getEarlyInstance(Dispatcher::class);
     }
     $this->dispatcher->dispatch(PackageManager::class, 'packageStatesUpdated');
 }
Esempio n. 13
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(Sequence::class, 'afterInvokeStep', function ($step) use($bootstrap, $dispatcher) {
             if ($step->getIdentifier() === 'neos.flow:systemfilemonitor') {
                 $templateFileMonitor = FileMonitor::createFileMonitorAtBoot('Fluid_TemplateFiles', $bootstrap);
                 $packageManager = $bootstrap->getEarlyInstance(PackageManagerInterface::class);
                 foreach ($packageManager->getActivePackages() as $packageKey => $package) {
                     if ($packageManager->isPackageFrozen($packageKey)) {
                         continue;
                     }
                     foreach (array('Templates', 'Partials', 'Layouts') as $path) {
                         $templatesPath = $package->getResourcesPath() . 'Private/' . $path;
                         if (is_dir($templatesPath)) {
                             $templateFileMonitor->monitorDirectory($templatesPath);
                         }
                     }
                 }
                 $templateFileMonitor->detectChanges();
                 $templateFileMonitor->shutdownObject();
             }
         });
     }
     // Use a closure to invoke the TemplateCompiler, since the object is not registered during compiletime
     $flushTemplates = function ($identifier, $changedFiles) use($bootstrap) {
         if ($identifier !== 'Fluid_TemplateFiles') {
             return;
         }
         if ($changedFiles === []) {
             return;
         }
         $templateCache = $bootstrap->getObjectManager()->get(CacheManager::class)->getCache('Fluid_TemplateCache');
         $templateCache->flush();
     };
     $dispatcher->connect(FileMonitor::class, 'filesHaveChanged', $flushTemplates);
 }
Esempio n. 14
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 = [];
     $availableCommands = $this->bootstrap->getObjectManager()->get(CommandManager::class)->getAvailableCommands();
     /** @var $command Command */
     foreach ($availableCommands as $command) {
         if ($command->isInternal() === false) {
             $suggestions[] = $command->getCommandIdentifier();
         }
     }
     return $suggestions;
 }
Esempio n. 15
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();
     $dispatcher->connect(PersistenceManager::class, 'allObjectsPersisted', NodeDataRepository::class, 'flushNodeRegistry');
     $dispatcher->connect(NodeDataRepository::class, 'repositoryObjectsPersisted', NodeDataRepository::class, 'flushNodeRegistry');
     $dispatcher->connect(Node::class, 'nodePathChanged', function () use($bootstrap) {
         $contextFactory = $bootstrap->getObjectManager()->get(ContextFactoryInterface::class);
         /** @var Context $contextInstance */
         foreach ($contextFactory->getInstances() as $contextInstance) {
             $contextInstance->getFirstLevelNodeCache()->flush();
         }
     });
     $dispatcher->connect(ConfigurationManager::class, 'configurationManagerReady', function (ConfigurationManager $configurationManager) {
         $configurationManager->registerConfigurationType('NodeTypes', ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_DEFAULT, true);
     });
     $context = $bootstrap->getContext();
     if (!$context->isProduction()) {
         $dispatcher->connect(Sequence::class, 'afterInvokeStep', function ($step) use($bootstrap) {
             if ($step->getIdentifier() === 'typo3.flow:systemfilemonitor') {
                 $nodeTypeConfigurationFileMonitor = FileMonitor::createFileMonitorAtBoot('TYPO3CR_NodeTypesConfiguration', $bootstrap);
                 $packageManager = $bootstrap->getEarlyInstance(PackageManagerInterface::class);
                 foreach ($packageManager->getActivePackages() as $packageKey => $package) {
                     if ($packageManager->isPackageFrozen($packageKey)) {
                         continue;
                     }
                     if (file_exists($package->getConfigurationPath())) {
                         $nodeTypeConfigurationFileMonitor->monitorDirectory($package->getConfigurationPath(), 'NodeTypes(\\..+)\\.yaml');
                     }
                 }
                 $nodeTypeConfigurationFileMonitor->monitorDirectory(FLOW_PATH_CONFIGURATION, 'NodeTypes(\\..+)\\.yaml');
                 $nodeTypeConfigurationFileMonitor->detectChanges();
                 $nodeTypeConfigurationFileMonitor->shutdownObject();
             }
         });
     }
 }
 /**
  * @return string
  */
 public function render()
 {
     $configuration = array('window.T3Configuration = {};', 'window.T3Configuration.UserInterface = ' . json_encode($this->settings['userInterface']) . ';', 'window.T3Configuration.nodeTypes = {};', 'window.T3Configuration.nodeTypes.groups = ' . json_encode($this->getNodeTypeGroupsSettings()) . ';', 'window.T3Configuration.requirejs = {};', 'window.T3Configuration.neosStaticResourcesBaseUri = ' . json_encode($this->resourceManager->getPublicPackageResourceUri('Neos.Neos', '')) . ';', 'window.T3Configuration.requirejs.paths = ' . json_encode($this->getRequireJsPathMapping()) . ';', 'window.T3Configuration.maximumFileUploadSize = ' . $this->renderMaximumFileUploadSize());
     $neosJavaScriptBasePath = $this->getStaticResourceWebBaseUri('resource://Neos.Neos/Public/JavaScript');
     $configuration[] = 'window.T3Configuration.neosJavascriptBasePath = ' . json_encode($neosJavaScriptBasePath) . ';';
     if ($this->backendAssetsUtility->shouldLoadMinifiedJavascript()) {
         $configuration[] = 'window.T3Configuration.neosJavascriptVersion = ' . json_encode($this->backendAssetsUtility->getJavascriptBuiltVersion()) . ';';
     }
     if ($this->bootstrap->getContext()->isDevelopment()) {
         $configuration[] = 'window.T3Configuration.DevelopmentMode = true;';
     }
     if ($activeDomain = $this->domainRepository->findOneByActiveRequest()) {
         $configuration[] = 'window.T3Configuration.site = "' . $activeDomain->getSite()->getNodeName() . '";';
     }
     return implode("\n", $configuration);
 }
Esempio n. 17
0
 /**
  * Returns TRUE if there is a session that can be resumed.
  *
  * If a to-be-resumed session was inactive for too long, this function will
  * trigger the expiration of that session. An expired session cannot be resumed.
  *
  * NOTE that this method does a bit more than the name implies: Because the
  * session info data needs to be loaded, this method stores this data already
  * so it doesn't have to be loaded again once the session is being used.
  *
  * @return boolean
  * @api
  */
 public function canBeResumed()
 {
     if ($this->request === null) {
         $this->initializeHttpAndCookie($this->bootstrap->getActiveRequestHandler());
     }
     if ($this->sessionCookie === null || $this->request === null || $this->started === true) {
         return false;
     }
     $sessionMetaData = $this->metaDataCache->get($this->sessionCookie->getValue());
     if ($sessionMetaData === false) {
         return false;
     }
     $this->lastActivityTimestamp = $sessionMetaData['lastActivityTimestamp'];
     $this->storageIdentifier = $sessionMetaData['storageIdentifier'];
     $this->tags = $sessionMetaData['tags'];
     return !$this->autoExpire();
 }
 /**
  * @param array<Command> $commands
  * @return void
  */
 protected function displayShortHelpForCommands(array $commands)
 {
     $commandsByPackagesAndControllers = $this->buildCommandsIndex($commands);
     foreach ($commandsByPackagesAndControllers as $packageKey => $commandControllers) {
         $this->outputLine('');
         $this->outputLine('PACKAGE "%s":', [strtoupper($packageKey)]);
         $this->outputLine(str_repeat('-', $this->output->getMaximumLineLength()));
         foreach ($commandControllers as $commands) {
             /** @var Command $command */
             foreach ($commands as $command) {
                 $description = wordwrap($command->getShortDescription(), $this->output->getMaximumLineLength() - 43, PHP_EOL . str_repeat(' ', 43), true);
                 $shortCommandIdentifier = $this->commandManager->getShortestIdentifierForCommand($command);
                 $compileTimeSymbol = $this->bootstrap->isCompileTimeCommand($shortCommandIdentifier) ? '*' : '';
                 $this->outputLine('%-2s%-40s %s', [$compileTimeSymbol, $shortCommandIdentifier, $description]);
             }
             $this->outputLine();
         }
     }
 }
 /**
  * Returns the form definitions for the step
  *
  * @param FormDefinition $formDefinition
  * @return void
  */
 protected function buildForm(FormDefinition $formDefinition)
 {
     $page1 = $formDefinition->createPage('page1');
     $page1->setRenderingOption('header', 'Setup complete');
     $congratulations = $page1->createElement('congratulationsSection', 'Neos.Form:Section');
     $congratulations->setLabel('Congratulations');
     $success = $congratulations->createElement('success', 'Neos.Form:StaticText');
     $success->setProperty('text', 'You have successfully installed Neos! If you need help getting started, please refer to the Neos documentation.');
     $success->setProperty('elementClassAttribute', 'alert alert-success');
     $docs = $congratulations->createElement('docsLink', 'Neos.Setup:LinkElement');
     $docs->setLabel('Read the documentation');
     $docs->setProperty('href', 'https://neos.readthedocs.org/');
     $docs->setProperty('target', '_blank');
     $contextEnv = Bootstrap::getEnvironmentConfigurationSetting('FLOW_CONTEXT') ?: 'Development';
     $applicationContext = new ApplicationContext($contextEnv);
     if (!$applicationContext->isProduction()) {
         $context = $page1->createElement('contextSection', 'Neos.Form:Section');
         $context->setLabel('Define application context');
         $contextInfo = $context->createElement('contextInfo', 'Neos.Form:StaticText');
         $contextInfo->setProperty('text', 'Your Neos installation is currently not running in "Production" context. If you want to experience Neos with its full speed, you should now change your FLOW_CONTEXT environment variable to "Production".');
         $contextDocs = $context->createElement('contextDocsLink', 'Neos.Setup:LinkElement');
         $contextDocs->setLabel('Read about application contexts');
         $contextDocs->setProperty('href', 'http://flowframework.readthedocs.org/en/stable/TheDefinitiveGuide/PartIII/Bootstrapping.html#the-typo3-flow-application-context');
         $contextDocs->setProperty('target', '_blank');
     }
     $frontend = $page1->createElement('frontendSection', 'Neos.Form:Section');
     $frontend->setLabel('View the site');
     $link = $frontend->createElement('link', 'Neos.Setup:LinkElement');
     $link->setLabel('Go to the frontend');
     $link->setProperty('href', '/');
     $link->setProperty('elementClassAttribute', 'btn btn-large btn-primary');
     $backend = $page1->createElement('backendSection', 'Neos.Form:Section');
     $backend->setLabel('Start editing');
     $backendLink = $backend->createElement('backendLink', 'Neos.Setup:LinkElement');
     $backendLink->setLabel('Go to the backend');
     $backendLink->setProperty('href', '/neos');
     $backendLink->setProperty('elementClassAttribute', 'btn btn-large btn-primary');
     $loggedOut = $page1->createElement('loggedOut', 'Neos.Form:StaticText');
     $loggedOut->setProperty('text', 'You have automatically been logged out for security reasons since this is the final step. Refresh the page to log in again if you missed something.');
     $loggedOut->setProperty('elementClassAttribute', 'alert alert-info');
 }
 /**
  * Flushes a particular cache by its identifier
  *
  * Given a cache identifier, this flushes just that one cache. To find
  * the cache identifiers, you can use the configuration:show command with
  * the type set to "Caches".
  *
  * Note that this does not have a force-flush option since it's not
  * meant to remove temporary code data, resulting into a broken state if
  * code files lack.
  *
  * @param string $identifier Cache identifier to flush cache for
  * @return void
  * @see neos.flow:cache:flush
  * @see neos.flow:configuration:show
  */
 public function flushOneCommand($identifier)
 {
     if (!$this->cacheManager->hasCache($identifier)) {
         $this->outputLine('The cache "%s" does not exist.', [$identifier]);
         $cacheConfigurations = $this->cacheManager->getCacheConfigurations();
         $shortestDistance = -1;
         foreach (array_keys($cacheConfigurations) as $existingIdentifier) {
             $distance = levenshtein($existingIdentifier, $identifier);
             if ($distance <= $shortestDistance || $shortestDistance < 0) {
                 $shortestDistance = $distance;
                 $closestIdentifier = $existingIdentifier;
             }
         }
         if (isset($closestIdentifier)) {
             $this->outputLine('Did you mean "%s"?', [$closestIdentifier]);
         }
         $this->quit(1);
     }
     $this->cacheManager->getCache($identifier)->flush();
     $this->outputLine('Flushed "%s" cache for "%s" context.', [$identifier, $this->bootstrap->getContext()]);
     $this->sendAndExit(0);
 }
 /**
  * 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 neos.flow:package:freeze
  * @see neos.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('neos.flow:cache:flush', $this->settings, false);
     $this->sendAndExit(0);
 }
 /**
  * Detects and returns the website's absolute base URI
  *
  * @return string The resolved resource base URI, @see getResourcesBaseUri()
  * @throws TargetException if the baseUri can't be resolved
  */
 protected function detectResourcesBaseUri()
 {
     if ($this->baseUri !== '' && ($this->baseUri[0] === '/' || strpos($this->baseUri, '://') !== false)) {
         return $this->baseUri;
     }
     $requestHandler = $this->bootstrap->getActiveRequestHandler();
     if ($requestHandler instanceof HttpRequestHandlerInterface) {
         return $requestHandler->getHttpRequest()->getBaseUri() . $this->baseUri;
     }
     if ($this->httpBaseUri === null) {
         throw new TargetException(sprintf('The base URI for resources could not be detected. Please specify the "Neos.Flow.http.baseUri" setting or use an absolute "baseUri" option for target "%s".', $this->name), 1438093977);
     }
     return $this->httpBaseUri . $this->baseUri;
 }
 /**
  * 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(CacheManager::class)->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 ChangeDetectionStrategy\ModificationTimeStrategy();
     $fileChangeDetector->injectCache($fileMonitorCache);
     $bootstrap->getObjectManager()->registerShutdownObject($fileChangeDetector, 'shutdownObject');
     $fileMonitor = new FileMonitor($identifier);
     $fileMonitor->injectCache($fileMonitorCache);
     $fileMonitor->injectChangeDetectionStrategy($fileChangeDetector);
     $fileMonitor->injectSignalDispatcher($bootstrap->getEarlyInstance(Dispatcher::class));
     $fileMonitor->injectSystemLogger($bootstrap->getEarlyInstance(SystemLoggerInterface::class));
     return $fileMonitor;
 }
Esempio n. 24
0
 /**
  * Invokes custom PHP code directly after the package manager has been initialized.
  *
  * @param \Neos\Flow\Core\Bootstrap $bootstrap The current bootstrap
  * @return void
  */
 public function boot(\Neos\Flow\Core\Bootstrap $bootstrap)
 {
     $bootstrap->registerRequestHandler(new \Neos\Setup\Core\RequestHandler($bootstrap));
 }
Esempio n. 25
0
 /**
  * @param Bootstrap $bootstrap The current bootstrap
  * @return void
  */
 public function boot(Bootstrap $bootstrap)
 {
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     $flushConfigurationCache = function () use($bootstrap) {
         $cacheManager = $bootstrap->getEarlyInstance(CacheManager::class);
         $cacheManager->getCache('TYPO3_Neos_Configuration_Version')->flush();
     };
     $flushXliffServiceCache = function () use($bootstrap) {
         $cacheManager = $bootstrap->getEarlyInstance(CacheManager::class);
         $cacheManager->getCache('TYPO3_Neos_XliffToJsonTranslations')->flush();
     };
     $dispatcher->connect(FileMonitor::class, 'filesHaveChanged', function ($fileMonitorIdentifier, array $changedFiles) use($flushConfigurationCache, $flushXliffServiceCache) {
         switch ($fileMonitorIdentifier) {
             case 'TYPO3CR_NodeTypesConfiguration':
             case 'Flow_ConfigurationFiles':
                 $flushConfigurationCache();
                 break;
             case 'Flow_TranslationFiles':
                 $flushConfigurationCache();
                 $flushXliffServiceCache();
         }
     });
     $dispatcher->connect(Site::class, 'siteChanged', $flushConfigurationCache);
     $dispatcher->connect(Site::class, 'siteChanged', RouterCachingService::class, 'flushCaches');
     $dispatcher->connect(Node::class, 'nodeUpdated', ContentCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(Node::class, 'nodeAdded', ContentCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(Node::class, 'nodeRemoved', ContentCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(Node::class, 'beforeNodeMove', ContentCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(AssetService::class, 'assetResourceReplaced', ContentCacheFlusher::class, 'registerAssetResourceChange');
     $dispatcher->connect(Node::class, 'nodeAdded', NodeUriPathSegmentGenerator::class, '::setUniqueUriPathSegment');
     $dispatcher->connect(Node::class, 'nodePropertyChanged', Service\ImageVariantGarbageCollector::class, 'removeUnusedImageVariant');
     $dispatcher->connect(Node::class, 'nodePropertyChanged', function (NodeInterface $node, $propertyName) use($bootstrap) {
         if ($propertyName === 'uriPathSegment') {
             NodeUriPathSegmentGenerator::setUniqueUriPathSegment($node);
             $bootstrap->getObjectManager()->get(RouteCacheFlusher::class)->registerNodeChange($node);
         }
     });
     $dispatcher->connect(Node::class, 'nodePathChanged', function (NodeInterface $node, $oldPath, $newPath, $recursion) {
         if (!$recursion) {
             NodeUriPathSegmentGenerator::setUniqueUriPathSegment($node);
         }
     });
     $dispatcher->connect(PublishingService::class, 'nodePublished', ContentCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(PublishingService::class, 'nodeDiscarded', ContentCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(Node::class, 'nodePathChanged', RouteCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(Node::class, 'nodeRemoved', RouteCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(PublishingService::class, 'nodeDiscarded', RouteCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(PublishingService::class, 'nodePublished', RouteCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(PublishingService::class, 'nodePublished', function ($node, $targetWorkspace) use($bootstrap) {
         $cacheManager = $bootstrap->getObjectManager()->get(CacheManager::class);
         if ($cacheManager->hasCache('Flow_Persistence_Doctrine')) {
             $cacheManager->getCache('Flow_Persistence_Doctrine')->flush();
         }
     });
     $dispatcher->connect(PersistenceManager::class, 'allObjectsPersisted', RouteCacheFlusher::class, 'commit');
     $dispatcher->connect(SiteService::class, 'sitePruned', ContentCache::class, 'flush');
     $dispatcher->connect(SiteService::class, 'sitePruned', RouterCachingService::class, 'flushCaches');
     $dispatcher->connect(SiteImportService::class, 'siteImported', ContentCache::class, 'flush');
     $dispatcher->connect(SiteImportService::class, 'siteImported', RouterCachingService::class, 'flushCaches');
     // Eventlog
     $dispatcher->connect(Node::class, 'beforeNodeCreate', ContentRepositoryIntegrationService::class, 'beforeNodeCreate');
     $dispatcher->connect(Node::class, 'afterNodeCreate', ContentRepositoryIntegrationService::class, 'afterNodeCreate');
     $dispatcher->connect(Node::class, 'nodeUpdated', ContentRepositoryIntegrationService::class, 'nodeUpdated');
     $dispatcher->connect(Node::class, 'nodeRemoved', ContentRepositoryIntegrationService::class, 'nodeRemoved');
     $dispatcher->connect(Node::class, 'beforeNodePropertyChange', ContentRepositoryIntegrationService::class, 'beforeNodePropertyChange');
     $dispatcher->connect(Node::class, 'nodePropertyChanged', ContentRepositoryIntegrationService::class, 'nodePropertyChanged');
     $dispatcher->connect(Node::class, 'beforeNodeCopy', ContentRepositoryIntegrationService::class, 'beforeNodeCopy');
     $dispatcher->connect(Node::class, 'afterNodeCopy', ContentRepositoryIntegrationService::class, 'afterNodeCopy');
     $dispatcher->connect(Node::class, 'beforeNodeMove', ContentRepositoryIntegrationService::class, 'beforeNodeMove');
     $dispatcher->connect(Node::class, 'afterNodeMove', ContentRepositoryIntegrationService::class, 'afterNodeMove');
     $dispatcher->connect(Context::class, 'beforeAdoptNode', ContentRepositoryIntegrationService::class, 'beforeAdoptNode');
     $dispatcher->connect(Context::class, 'afterAdoptNode', ContentRepositoryIntegrationService::class, 'afterAdoptNode');
     $dispatcher->connect(Workspace::class, 'beforeNodePublishing', ContentRepositoryIntegrationService::class, 'beforeNodePublishing');
     $dispatcher->connect(Workspace::class, 'afterNodePublishing', ContentRepositoryIntegrationService::class, 'afterNodePublishing');
     $dispatcher->connect(PersistenceManager::class, 'allObjectsPersisted', ContentRepositoryIntegrationService::class, 'updateEventsAfterPublish');
     $dispatcher->connect(NodeDataRepository::class, 'repositoryObjectsPersisted', ContentRepositoryIntegrationService::class, 'updateEventsAfterPublish');
 }
Esempio n. 26
0
 /**
  * @param Bootstrap $bootstrap The current bootstrap
  * @return void
  */
 public function boot(Bootstrap $bootstrap)
 {
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     $dispatcher->connect(Workspace::class, 'beforeNodePublishing', NodeRedirectService::class, 'createRedirectsForPublishedNode');
 }
Esempio n. 27
0
 /**
  * @param Bootstrap $bootstrap The current bootstrap
  * @return void
  */
 public function boot(Bootstrap $bootstrap)
 {
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     $dispatcher->connect(AssetService::class, 'assetCreated', ThumbnailGenerator::class, 'createThumbnails');
 }
<?php

/*
 * This file configures dynamic return type support for factory methods in PhpStorm
 */
namespace PHPSTORM_META;

$STATIC_METHOD_TYPES = [\Neos\Flow\ObjectManagement\ObjectManagerInterface::get('') => ['' == '@'], \Neos\Flow\Core\Bootstrap::getEarlyInstance('') => ['' == '@']];
Esempio n. 29
0
<?php

/*
 * This file is part of the Neos.Flow package.
 *
 * (c) Contributors of the Neos Project - www.neos.io
 *
 * This package is Open Source Software. For the full copyright and license
 * information, please view the LICENSE file which was distributed with this
 * source code.
 */
$rootPath = isset($_SERVER['FLOW_ROOTPATH']) ? $_SERVER['FLOW_ROOTPATH'] : false;
if ($rootPath === false && isset($_SERVER['REDIRECT_FLOW_ROOTPATH'])) {
    $rootPath = $_SERVER['REDIRECT_FLOW_ROOTPATH'];
}
if ($rootPath === false) {
    $rootPath = dirname(__FILE__) . '/../';
} elseif (substr($rootPath, -1) !== '/') {
    $rootPath .= '/';
}
require $rootPath . 'Packages/Framework/Neos.Flow/Classes/Core/Bootstrap.php';
$context = \Neos\Flow\Core\Bootstrap::getEnvironmentConfigurationSetting('FLOW_CONTEXT') ?: 'Development';
$bootstrap = new \Neos\Flow\Core\Bootstrap($context);
$bootstrap->run();
 /**
  * Initialize the stream wrappers.
  *
  * @param Bootstrap $bootstrap
  * @return void
  */
 public static function initializeResources(Bootstrap $bootstrap)
 {
     StreamWrapperAdapter::initializeStreamWrapper($bootstrap->getObjectManager());
 }